From 41a6e7bbfadff3767c3719c6d65443d8f50f82ec Mon Sep 17 00:00:00 2001 From: Andrea Calia Date: Wed, 16 May 2018 17:36:04 +0200 Subject: [PATCH] latest jmad-core. Deployment scripts --- build.gradle | 45 +++++++++++++++++++- scripts/bintray-deploy.gradle | 77 +++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 scripts/bintray-deploy.gradle diff --git a/build.gradle b/build.gradle index cf6a81a..499d62c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,49 @@ +buildscript { + project.ext.DEPLOYMENT = System.getProperty('deployment') ?: false + project.ext.VCS_TAG = System.getProperty('TRAVIS_TAG') ?: System.getenv('TRAVIS_TAG') + project.ext.POM = [ + groupId : 'jmad', + artifactId : 'jmad-modelpack-service', + description: 'Service to retrieve JMad model packages from different sources.' + ] + project.ext.INFO = [ + repo : 'https://github.com/jmad/jmad-modelpack-service.git', + url : 'https://jmad.github.io/', + github : 'https://github.com/jmad/jmad-modelpack-service', + githubIssues : 'https://github.com/jmad/jmad-modelpack-service/issues', + licenseNameShort: 'Apache-2.0', + licenseName : 'The Apache License, Version 2.0', + licenseUrl : 'http://www.apache.org/licenses/LICENSE-2.0.txt' + ] + project.ext.BINTRAY = [ + repo : 'jmad-repo', + name : 'jmad-modelpack-service', + organization: 'jmad', + userName : System.getProperty('BINTRAY_USER') ?: System.getenv('BINTRAY_USER'), + apiToken : System.getProperty('BINTRAY_API_TOKEN') ?: System.getenv('BINTRAY_API_TOKEN') + ] + + repositories { + jcenter() + } + dependencies { + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' + } + +} + plugins { id 'java' id 'jacoco' + id 'maven-publish' + id 'com.jfrog.bintray' version '1.7.3' +} + +sourceCompatibility = JavaVersion.VERSION_1_8 + +if (DEPLOYMENT) { + println 'Applying deployment scripts' + apply from: './scripts/bintray-deploy.gradle' } repositories { @@ -9,7 +52,7 @@ repositories { } dependencies { - compile group: 'jmad', name: 'jmad-core', version: '0.1.1' + compile group: 'jmad', name: 'jmad-core', version: '0.1.2' compile group: 'org.springframework', name: 'spring-core', version: '5.0.6.RELEASE' compile group: 'org.springframework', name: 'spring-context', version: '5.0.6.RELEASE' diff --git a/scripts/bintray-deploy.gradle b/scripts/bintray-deploy.gradle new file mode 100644 index 0000000..3d4b3a9 --- /dev/null +++ b/scripts/bintray-deploy.gradle @@ -0,0 +1,77 @@ +project.ext.getDeploymentVersion = { + if(VCS_TAG == null) { + throw new RuntimeException("VCS_TAG is not set. Cannot detect deployment version") + } + String tmpDeploymentVersion = VCS_TAG.replaceFirst("v", ""); + if (!tmpDeploymentVersion.matches("\\d+\\.\\d+\\.\\d+")) { + throw new RuntimeException("Version is not valid. Correct format is like 1.0.2 but was " + tmpDeploymentVersion) + } + return tmpDeploymentVersion; +} + +bintrayUpload.doFirst { + println "Deploying version ${getDeploymentVersion()} from vscTag ${VCS_TAG}" +} + +bintray { + user = "${BINTRAY.userName}" + key = "${BINTRAY.apiToken}" + + publications = ['CustomMavenPublication'] + // When uploading Maven-based publication files. Nebula is because we're using the netflix plugins and they use nebula as default name for a publication + dryRun = !DEPLOYMENT // Whether to run this as dry-run, without deploying + publish = DEPLOYMENT // Whether version should be auto published after an upload + override = false // Whether to override version artifacts already published + + pkg { + repo = "${BINTRAY.repo}" + name = "${BINTRAY.name}" + userOrg = "${BINTRAY.organization}" + websiteUrl = "${INFO.github}" + issueTrackerUrl = "${INFO.githubIssues}" + vcsUrl = "${INFO.repo}" + licenses = [INFO.licenseNameShort] + + version { + name = getDeploymentVersion() + released = new Date() + vcsTag = VCS_TAG + gpg { sign = true } + } + } +} + +def pomExtraInfo = { + url INFO.url + scm { + connection "scm:git:${INFO.repo}" + developerConnection "scm:git:${INFO.repo}" + url INFO.repo + } + licenses { + license { + name INFO.licenseName + url INFO.licenseUrl + } + } +} + +publishing { + publications { + CustomMavenPublication(MavenPublication) { + groupId POM.groupId + artifactId POM.artifactId + version getDeploymentVersion() + + artifact sourcesJar + artifact javadocJar + + pom.withXml { + asNode().appendNode('description', POM.description) + asNode().children().last() + pomExtraInfo + } + + from components.java + } + } +}