diff --git a/.travis.yml b/.travis.yml index 0b93063..247a5af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,13 @@ jobs: if: tag =~ ^v script: - ./prepare_before_publish - - ./gradlew publish - -after_script: - - ./clean_after_publish \ No newline at end of file + - ./gradlew core:publish + - ./cleanup_after_publish + + # - stage: release + # name: "Publish snapshot" + # if: branch =~ ^(hotfix|release)\/.* + # script: + # - ./prepare_before_publish + # - ./gradlew core:publish -PSNAPSHOT=true + # - ./cleanup_after_publish \ No newline at end of file diff --git a/build.gradle b/build.gradle index e8af26a..09f5576 100644 --- a/build.gradle +++ b/build.gradle @@ -9,19 +9,24 @@ plugins { // Apply the java-library plugin to add support for Java Library id 'java-library' - id 'maven-publish' - id 'signing' } repositories { jcenter() } +dependencies { + compile project(':core') + compile project(':simple-middlewares') +} + allprojects { apply plugin: 'jacoco' apply plugin: 'checkstyle' apply plugin: 'pmd' apply plugin: 'findbugs' + apply plugin: 'maven-publish' + apply plugin: 'signing' checkstyle { toolVersion = '8.18' @@ -54,100 +59,103 @@ allprojects { options.compilerArgs << "-Werror" } } -} - -task sourceJar(type: Jar) { - classifier "sources" - from sourceSets.main.allJava -} -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier "javadoc" - from javadoc.destinationDir -} + task sourceJar(type: Jar) { + classifier "sources" + from sourceSets.main.allJava + } -artifacts { - archives jar - archives sourceJar - archives javadocJar -} + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier "javadoc" + from javadoc.destinationDir + } -publishing { - publications { - mavenJava(MavenPublication) { - customizePom(pom) - groupId 'net.dathoang.cqrs.commandbus' - artifactId 'core' - version '0.1.0' + artifacts { + archives jar + archives sourceJar + archives javadocJar + } - from components.java + publishing { + publications { + mavenJava(MavenPublication) { + customizePom(pom) + groupId 'net.dathoang.cqrs.commandbus' + version '0.1.1' - artifact(sourceJar) { - classifier = 'sources' - } - artifact(javadocJar) { - classifier = 'javadoc' - } + from components.java - // Create the sign pom artifact - pom.withXml { - def pomFile = file("${project.buildDir}/generated-pom.xml") - writeTo(pomFile) - def pomAscFile = signing.sign(pomFile).signatureFiles[0] - artifact(pomAscFile) { - classifier = null - extension = 'pom.asc' + artifact(sourceJar) { + classifier = 'sources' + } + artifact(javadocJar) { + classifier = 'javadoc' } - } - // Create the signed artifacts - project.tasks.signArchives.signatureFiles.each { - artifact(it) { - def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/ - if (matcher.find()) { - classifier = matcher.group(1) - } else { + // Create the sign pom artifact + pom.withXml { + def pomFile = file("${project.buildDir}/generated-pom.xml") + writeTo(pomFile) + def pomAscFile = signing.sign(pomFile).signatureFiles[0] + artifact(pomAscFile) { classifier = null + extension = 'pom.asc' + } + } + + // Create the signed artifacts + project.tasks.signArchives.signatureFiles.each { + artifact(it) { + def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/ + if (matcher.find()) { + classifier = matcher.group(1) + } else { + classifier = null + } + extension = 'jar.asc' } - extension = 'jar.asc' } } } - } - repositories { - maven { - url "https://oss.sonatype.org/service/local/staging/deploy/maven2" - credentials { - username project.properties['CQRS_COMMANDBUS_SONATYPE_USERNAME'] - password project.properties['CQRS_COMMANDBUS_SONATYPE_PASSWORD'] + repositories { + maven { + if (project.properties['SNAPSHOT'] != 'true') { + url "https://oss.sonatype.org/service/local/staging/deploy/maven2" + } else { + url "https://oss.sonatype.org/content/repositories/snapshots" + } + credentials { + username project.properties['CQRS_COMMANDBUS_SONATYPE_USERNAME'] + password project.properties['CQRS_COMMANDBUS_SONATYPE_PASSWORD'] + } } } } -} -model { - tasks.generatePomFileForMavenJavaPublication { - destination = file("$buildDir/generated-pom.xml") - } + model { + tasks.generatePomFileForMavenJavaPublication { + destination = file("$buildDir/generated-pom.xml") + } - tasks.publishMavenJavaPublicationToMavenLocal { - dependsOn project.tasks.signArchives - } - tasks.publishMavenJavaPublicationToMavenRepository { - dependsOn project.tasks.signArchives + tasks.publishMavenJavaPublicationToMavenLocal { + dependsOn project.tasks.signArchives + } + tasks.publishMavenJavaPublicationToMavenRepository { + dependsOn project.tasks.signArchives + } } -} -signing { - sign configurations.archives -} + signing { + sign configurations.archives + } -gradle.taskGraph.whenReady { taskGraph -> - if (taskGraph.allTasks.any { it instanceof Sign }) { - allprojects { - ext."signing.keyId" = project.properties['CQRS_COMMANDBUS_SIGNING_KEY_ID'] - ext."signing.secretKeyRingFile" = project.properties['CQRS_COMMANDBUS_SECRET_KEYRING_FILE'] - ext."signing.password" = project.properties['CQRS_COMMANDBUS_SIGNING_PASSWORD'] + gradle.taskGraph.whenReady { taskGraph -> + if (taskGraph.allTasks.any { it instanceof Sign }) { + allprojects { + ext."signing.keyId" = project.properties['CQRS_COMMANDBUS_SIGNING_KEY_ID'] + ext."signing.secretKeyRingFile" = project.properties['CQRS_COMMANDBUS_SECRET_KEYRING_FILE'] + ext."signing.password" = project.properties['CQRS_COMMANDBUS_SIGNING_PASSWORD'] + } } } } diff --git a/cleanup_after_publish b/cleanup_after_publish index 4335d06..7451241 100755 --- a/cleanup_after_publish +++ b/cleanup_after_publish @@ -1,3 +1,3 @@ #!/bin/bash -rm -f .secret_ring \ No newline at end of file +rm -f core/.secret_ring \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 9fb14af..27c0bf5 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -43,3 +43,11 @@ jacocoTestReport { html.enabled false } } + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId 'core' + } + } +} diff --git a/core/src/main/java/net/dathoang/cqrs/commandbus/middleware/PipelineContextContainer.java b/core/src/main/java/net/dathoang/cqrs/commandbus/middleware/PipelineContextContainer.java index f601078..9cc04f7 100644 --- a/core/src/main/java/net/dathoang/cqrs/commandbus/middleware/PipelineContextContainer.java +++ b/core/src/main/java/net/dathoang/cqrs/commandbus/middleware/PipelineContextContainer.java @@ -13,7 +13,7 @@ public interface PipelineContextContainer { * Get the handling data of the middleware for the current command. * @param middlewareClass the class of the current middleware (for name-spacing) * @param key the key of the data - * @return the data at key {@param key} for the middleware {@param middlewareClass} + * @return the data at key key for the middleware middlewareClass */ Object getMiddlewareData(Class middlewareClass, String key); @@ -26,7 +26,7 @@ public interface PipelineContextContainer { void setMiddlewareData(Class middlewareClass, String key, Object value); /** - * Set the context instance {@param instance} to be injected into inner middleware in the pipeline + * Set the context instance to be injected into inner middleware in the pipeline * or into the command handler. * The current middleware's context injection supports: * - Method injection @@ -37,7 +37,7 @@ public interface PipelineContextContainer { * {@link MiddlewareContext} annotation instead of @Context annotation. * * @param contextClass the class type of the context. - * @param instance the context instance which will be provided to the inner middleware & command + * @param instance the context instance which will be provided to the inner middleware and command * handler. * @param the type of the context. */ diff --git a/prepare_before_publish b/prepare_before_publish index 48f5a71..488b372 100755 --- a/prepare_before_publish +++ b/prepare_before_publish @@ -1,3 +1,3 @@ #!/bin/bash -echo $CQRS_COMMANDBUS_GPG_SECRET_RING_BASE64 | base64 --decode > .secret_ring \ No newline at end of file +echo $CQRS_COMMANDBUS_GPG_SECRET_RING_BASE64 | base64 --decode > core/.secret_ring \ No newline at end of file