Skip to content

Commit

Permalink
release automation #294
Browse files Browse the repository at this point in the history
- publishing to bintray
- release pages on www.crnk.io
  • Loading branch information
remmeier committed Apr 30, 2018
1 parent fd8078a commit 34f3e8b
Show file tree
Hide file tree
Showing 18 changed files with 1,010 additions and 125 deletions.
180 changes: 96 additions & 84 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ buildscript {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5-rc1'
classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.1"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}

Expand All @@ -29,9 +31,11 @@ ext {
timestampedVersion = isProductionBuild
}

SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss")
apply plugin: 'org.ajoberstar.grgit'

if (ext.timestampedVersion) {
version = BUILD_VERSION_PREFIX + "." + format.format(new Date())
def gitCommitTimestamp = grgit.head().date.format("yyyyMMddHHmmss", TimeZone.getTimeZone('GMT'))
version = BUILD_VERSION_PREFIX + "." + gitCommitTimestamp
} else {
version = '0.0.0-SNAPSHOT'
}
Expand Down Expand Up @@ -65,6 +69,8 @@ gradle.beforeProject { Project project ->
targetCompatibility = 1.8

if (!bom) {


dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
Expand Down Expand Up @@ -134,99 +140,43 @@ gradle.beforeProject { Project project ->
apply plugin: 'maven-publish'


if (!docs && !examples) {

if (isProductionBuild) {
apply plugin: 'signing'

if (!docs && !examples && !ui) {

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}

task javadocJar(type: Jar, dependsOn: 'javadoc') {
from javadoc.destinationDir
classifier = 'javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
task javadocJar(type: Jar, dependsOn: 'javadoc') {
from javadoc.destinationDir
classifier = 'javadoc'
}

ext.'signing.secretKeyRingFile' = "${rootProject.projectDir}/secring.gpg"
apply plugin: 'com.jfrog.bintray'

signing {
required {
gradle.taskGraph.hasTask("uploadArchives")
// Create the pom configuration:
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

// if(!System.env.NEXUS_DEPLOY_PASS){
// throw new IllegalStateException("NEXUS_DEPLOY_PASS not specified in environment")
// }

repository(url: NEXUS_DEPLOY_URL) {
authentication(
userName: System.env.NEXUS_DEPLOY_USER,
password: System.env.NEXUS_DEPLOY_PASS
)

// that plugin does not make use of global proxy settings :-(
def proxyHost = System.getProperty("https.proxyHost")
def proxyPort = System.getProperty("https.proxyPort")
if (proxyHost && proxyPort) {
proxy(host: proxyHost, port: Integer.parseInt(proxyPort), type: 'http')
}
}

pom.project {
name project.name
description 'JSON API framework for Java'
url 'http://www.crnk.io'
scm {
url 'https://github.com/crnk-project/crnk-framework'
connection 'scm:git:git://github.com/crnk-project/crnk-framework.git'
developerConnection 'scm:git:[email protected]:crnk-project/crnk-framework.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.html'
distribution 'repo'
}
}
issueManagement {
system 'GitHub'
url 'https://github.com/crnk-project/crml-framework/issues'
}
developers {
developer {
id 'crnk.io'
name 'crnk.io'
email '[email protected]'
}
}
}
}
developers {
developer {
id 'crnk.io'
name 'crnk.io'
email '[email protected]'
}
}

tasks.publish.dependsOn(tasks.uploadArchives)
} else {
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
scm {
url "https://github.com/crnk-project/crnk-framework"
}
}

if (!bom) {
publishing {
publications {
mavenJava(MavenPublication) {
Expand All @@ -235,11 +185,73 @@ gradle.beforeProject { Project project ->
artifact sourcesJar {
classifier "sources"
}

artifact javadocJar {
classifier "javadoc"
}

groupId GROUP_ID
artifactId project.name
version project.version

pom.withXml {
def root = asNode()
root.appendNode('description', 'JSON API with Crnk')
root.appendNode('name', 'Crnk')
root.appendNode('url', 'http://wwww.crnk.io')
root.children().last() + pomConfig
}
}
}
}
}


bintray {
user = System.env.BINTRAY_USER
key = System.env.BINTRAY_TOKEN

publications = ['mavenJava']

pkg {
repo = 'maven'
name = project.name
userOrg = 'crnk-project'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/crnk-project/crnk-framework.git'
websiteUrl = 'http://www.crnk.io'
desc = 'JSON API with Crnk'
labels = ['JSONAPI', 'rest']

githubRepo = 'crnk-project/crnk-framework'
githubReleaseNotesFile = 'README.md'

publish = true

version {
name = project.version
desc = 'JSON API with Crnk'
released = new Date()
vcsTag = "v$project.version"


mavenCentralSync {
sync = true //[Default: true] Determines whether to sync the version to Maven Central.
user = System.env.NEXUS_DEPLOY_USER
password = System.env.NEXUS_DEPLOY_PASS
close = '1'
}
}


}
}

tasks.bintrayUpload.dependsOn assemble, sourcesJar, javadocJar, publishToMavenLocal

publish.dependsOn tasks.bintrayUpload


}

}
Expand Down
18 changes: 3 additions & 15 deletions crnk-bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,10 @@ def bomGenerator = {
}
}

uploadArchives {
repositories {
mavenDeployer {
publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml bomGenerator
}
}
}

if (!rootProject.timestampedVersion) {
// dev build

publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml bomGenerator
}
}
}
}
2 changes: 2 additions & 0 deletions crnk-core/src/main/java/io/crnk/core/boot/CrnkBoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private static String buildServiceUrl(String resourceDefaultDomain, String webPa
*/
public void putServerInfo(String key, String value) {
serverInfo.put(key, value);

moduleRegistry.setServerInfo(serverInfo);
}

public void setServiceDiscoveryFactory(ServiceDiscoveryFactory factory) {
Expand Down
11 changes: 11 additions & 0 deletions crnk-core/src/main/java/io/crnk/core/module/ModuleRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public class ModuleRegistry {

private ResultFactory resultFactory;

private Map<String, String> serverInfo;


enum InitializedState {
NOT_INITIALIZED,
INITIALIZING,
Expand Down Expand Up @@ -129,6 +132,14 @@ public List<ResourceModificationFilter> getResourceModificationFilters() {
return prioritze(aggregatedModule.getResourceModificationFilters());
}

public void setServerInfo(Map<String, String> serverInfo) {
this.serverInfo = serverInfo;
}

public Map<String, String> getServerInfo() {
return serverInfo;
}

public ResultFactory getResultFactory() {
if (resultFactory == null) {
throw new IllegalStateException("resultFactory not yet available");
Expand Down
Loading

0 comments on commit 34f3e8b

Please sign in to comment.