ern-container-publisher-jcenter
Version:
Electrode Native JCenter Container Publisher
80 lines (79 loc) • 3.71 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ern_core_1 = require("ern-core");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const { execp } = ern_core_1.childProcess;
class JcenterPublisher {
get name() {
return 'jcenter';
}
get platforms() {
return ['android'];
}
publish({ containerPath, containerVersion, extra, }) {
return __awaiter(this, void 0, void 0, function* () {
if (!extra) {
throw new Error('artifactId, groupId must be provided to this publisher');
}
if (!extra.artifactId) {
throw new Error('artifactId must be provided to this publisher');
}
if (!extra.groupId) {
throw new Error('groupId must be provided to this publisher');
}
const mustacheConfig = {};
mustacheConfig.artifactId = extra.artifactId;
mustacheConfig.groupId = extra.groupId;
mustacheConfig.containerVersion = containerVersion;
fs_1.default.appendFileSync(path_1.default.join(containerPath, 'lib', 'build.gradle'), `
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}
artifacts {
archives androidSourcesJar
}
apply from: 'jcenter-publish.gradle'
`);
fs_1.default.appendFileSync(path_1.default.join(containerPath, 'build.gradle'), `buildscript {
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
}
}`);
ern_core_1.shell.cp(path_1.default.join(__dirname, 'supplements', 'jcenter-publish.gradle'), path_1.default.join(containerPath, 'lib'));
ern_core_1.mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(path_1.default.join(containerPath, 'lib', 'jcenter-publish.gradle'), mustacheConfig, path_1.default.join(containerPath, 'lib', 'jcenter-publish.gradle'));
try {
ern_core_1.log.info('[=== Starting build and jcenter publication ===]');
ern_core_1.shell.pushd(containerPath);
yield this.buildAndUploadArchive();
ern_core_1.log.info('[=== Completed build and publication of the Container ===]');
ern_core_1.log.info(`[Artifact: ${extra.groupId}:${extra.artifactId}:${containerVersion} ]`);
}
finally {
ern_core_1.shell.popd();
}
});
}
buildAndUploadArchive() {
return __awaiter(this, void 0, void 0, function* () {
const gradlew = /^win/.test(process.platform) ? 'gradlew' : './gradlew';
yield execp(`${gradlew} build`);
return execp(`${gradlew} bintrayUpload`);
});
}
}
exports.default = JcenterPublisher;
//# sourceMappingURL=index.js.map