Skip to content

Commit

Permalink
build: add required configuration for publishing to maven central
Browse files Browse the repository at this point in the history
This patch ...

* ... adds meta information for license, scm or developers to the
pom.xml which is required by maven central.

* adds a task to create a test Javadoc artifact, which is required by
maven central.

* adds fixes for violations in the test Javadoc

* adds the script 'publishToMaven.sh' which can be used to add required
credentials when publishing to maven central.
  • Loading branch information
pk-work committed Mar 10, 2021
1 parent 92dbcde commit 9cc50e4
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
.idea
.iml

# XMake #
######################
/.xmake/
/gen/
/import/

Expand Down
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ License: EPL-2.0

#### NeonBee Build

Files: Dockerfile gradle.properties *.gradle gradle/spotless/* gradle/pmd/* gradle/checkstyle/* gradle/gitlog/* gradle/release.sh .github/*
Files: Dockerfile gradle.properties *.gradle gradle/spotless/* gradle/pmd/* gradle/checkstyle/* gradle/gitlog/* gradle/release.sh .github/* publishToMaven.sh
Copyright: 2019 SAP SE or an SAP affiliate company and NeonBee contributors
License: EPL-2.0

Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ plugins {
}

group = 'io.neonbee'
// have to use single quotes for XMake, change as soon as new version Gradle build plugin is merged
version = '0.0.8'
version = '0.2.2'
mainClassName = 'io.neonbee.Launcher'
archivesBaseName = 'neonbee-core'
sourceCompatibility = 11
Expand Down
19 changes: 18 additions & 1 deletion gradle/distribution.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ task testJar(type: Jar) {
archiveExtension = 'jar'
}

/** Builds the sources JAR */
/** Builds the test sources JAR */
task testSourcesJar(type: Jar) {
from sourceSets.test.allJava

Expand All @@ -90,6 +90,22 @@ task testSourcesJar(type: Jar) {
archiveClassifier = 'sources'
}

task testJavadoc(type: Javadoc) {
classpath += sourceSets.test.compileClasspath
classpath += sourceSets.main.compileClasspath
source = sourceSets.test.allJava
}

/** Builds the test JavaDoc JAR */
task testJavadocJar(type: Jar) {
from testJavadoc

destinationDirectory = file("${buildDir}")

archiveAppendix = 'test'
archiveClassifier = 'javadoc'
}

// ##################### Source for Artifact neonbee-dist

/*
Expand Down Expand Up @@ -183,5 +199,6 @@ build {
dependsOn('javadocJar')
dependsOn('testJar')
dependsOn('testSourcesJar')
dependsOn('testJavadocJar')
dependsOn('distTar')
}
156 changes: 152 additions & 4 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
repositories {
mavenLocal()
}

publications {
// NeonBee Core Jar
core(MavenPublication) {
Expand All @@ -13,6 +10,49 @@ publishing {
artifact source: shadowJar
artifact source: sourcesJar
artifact source: javadocJar

pom {
name = 'NeonBee Core'
description = 'NeonBee is an open source reactive dataflow engine, a data stream processing framework using Vert.x.'
url = 'https://neonbee.io/'

licenses {
license {
name = 'Eclipse Public License version 2.0'
url = 'https://opensource.org/licenses/EPL-2.0'
}
}

scm {
connection = 'scm:git:https://github.com/SAP/neonbee.git'
developerConnection = 'scm:git:git@github.com:SAP/neonbee.git'
url = 'https://github.com/sap/neonbee'
}

developers {
developer {
id = 'pascal'
name = 'Pascal'
email = 'pascal@neonbee.io'
}
developer {
id = 'kristian'
name = 'Kristian'
email = 'kristian@neonbee.io'
}
developer {
id = 'sebastian'
name = 'Sebastian'
email = 'sebastian@neonbee.io'
}
developer {
id = 'danilo'
name = 'Danilo'
email = 'danilo@neonbee.io'
}
}
}

pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the implementation dependencies and add them to the pom.xml
Expand All @@ -29,13 +69,99 @@ publishing {
dist(MavenPublication) {
artifactId = 'neonbee-dist'
artifact source: distTar

pom {
name = 'NeonBee Core Distribution'
description = 'NeonBee is an open source reactive dataflow engine, a data stream processing framework using Vert.x.'
url = 'https://neonbee.io/'

licenses {
license {
name = 'Eclipse Public License version 2.0'
url = 'https://opensource.org/licenses/EPL-2.0'
}
}

scm {
connection = 'scm:git:https://github.com/SAP/neonbee.git'
developerConnection = 'scm:git:git@github.com:SAP/neonbee.git'
url = 'https://github.com/sap/neonbee'
}

developers {
developer {
id = 'pascal'
name = 'Pascal'
email = 'pascal@neonbee.io'
}
developer {
id = 'kristian'
name = 'Kristian'
email = 'kristian@neonbee.io'
}
developer {
id = 'sebastian'
name = 'Sebastian'
email = 'sebastian@neonbee.io'
}
developer {
id = 'danilo'
name = 'Danilo'
email = 'danilo@neonbee.io'
}
}
}
}

// NeonBee Test Jar
test(MavenPublication) {
artifactId = "${project.archivesBaseName}-test"
artifact source: testJar
artifact source: testSourcesJar
artifact source: testJavadocJar

pom {
name = 'NeonBee Core Test'
description = 'NeonBee is an open source reactive dataflow engine, a data stream processing framework using Vert.x.'
url = 'https://neonbee.io/'

licenses {
license {
name = 'Eclipse Public License version 2.0'
url = 'https://opensource.org/licenses/EPL-2.0'
}
}

scm {
connection = 'scm:git:https://github.com/SAP/neonbee.git'
developerConnection = 'scm:git:git@github.com:SAP/neonbee.git'
url = 'https://github.com/sap/neonbee'
}

developers {
developer {
id = 'pascal'
name = 'Pascal'
email = 'pascal@neonbee.io'
}
developer {
id = 'kristian'
name = 'Kristian'
email = 'kristian@neonbee.io'
}
developer {
id = 'sebastian'
name = 'Sebastian'
email = 'sebastian@neonbee.io'
}
developer {
id = 'danilo'
name = 'Danilo'
email = 'danilo@neonbee.io'
}
}
}

pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the implementation dependencies and add them to the pom.xml
Expand All @@ -61,4 +187,26 @@ publishing {
}
}
}

repositories {
maven {
name = 'mavenCentral'
credentials(PasswordCredentials)
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}

signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")

if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.core
sign publishing.publications.dist
sign publishing.publications.test
}
}
12 changes: 12 additions & 0 deletions publishToMaven.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

export ORG_GRADLE_PROJECT_signingPassword=EnterSigningPasswordHere
export ORG_GRADLE_PROJECT_signingKey=EnterContentOfKeyArmorFileHere # e.g.:`cat ~/NeonBeePrivate.asc`

export ORG_GRADLE_PROJECT_mavenCentralUsername=ossrh-jira-user
export ORG_GRADLE_PROJECT_mavenCentralPassword=ossrh-jira-password

cd "${SCRIPTPATH}"
./gradlew publishAllPublicationsToMavenCentralRepository
2 changes: 2 additions & 0 deletions src/test/java/io/neonbee/hook/internal/HookClassTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class HookClassTemplate implements ClassTemplate {
/**
* Creates a dummy hook class.
*
* @param hookTemplate The path to the template file for the hook.
* @param simpleClassName The simple class name of the new class
* @throws IOException Hook template could not be read
*/
Expand All @@ -49,6 +50,7 @@ public HookClassTemplate(Path hookTemplate, String simpleClassName) throws IOExc
/**
* Creates a dummy hook class.
*
* @param hookTemplate The path to the template file for the hook.
* @param simpleClassName The simple class name of the new class
* @param packageName The package name of the class. Pass null for default package
* @throws IOException Hook template could not be read
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/io/neonbee/internal/BasicJar.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ public BasicJar(Map<String, byte[]> content) {
}

/**
* Creates a jar file with the passed content and an default manifest which only contains the manifest version
* Creates a jar file with the passed content and manifest.
*
* @param content The content of the jar file
* @param content The content of the jar file
* @param manifestAttributes The manifest of the jar file
*/
public BasicJar(Map<String, String> manifestAttributes, Map<String, byte[]> content) {
this(createManifest(manifestAttributes), content.entrySet().stream()
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/neonbee/internal/ClassTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface ClassTemplate {
String getPackageName();

/**
* @see Class#getName();
* @see Class#getName()
*
* @return The full qualified class name of the verticle
*/
Expand Down
8 changes: 7 additions & 1 deletion src/test/java/io/neonbee/internal/NeonBeeModuleJar.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public NeonBeeModuleJar(String name, List<ClassTemplate> verticleTemplates, Map<

/**
* @see NeonBeeModuleJar#createManifest(String, Collection, Collection, Collection, Collection)
*
* @param name The module name / identifier
* @param deployables The deployables
* @return A Manifest with the passed deployables
*/
public static Manifest createManifest(String name, Collection<String> deployables) {
return createManifest(name, deployables, List.of(), List.of(), List.of());
Expand All @@ -40,9 +44,11 @@ public static Manifest createManifest(String name, Collection<String> deployable
* Generates a Manifest file with the attribute NeonBee-Deployables which contains the passed verticle deployables
* and the attribute NeonBee-Models which contains the passed model paths.
*
* @param deployables The deployables
* @param name The module name / identifier
* @param deployables The FQN of the deployables
* @param modelPaths The paths to the model files (*.csn) inside of the JAR
* @param extensionModelPaths The paths to the extension model files (*.edmx) inside of the JAR
* @param hooks The FQN of the hooks
* @return A Manifest with the passed deployables
*/
public static Manifest createManifest(String name, Collection<String> deployables, Collection<String> modelPaths,
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/io/neonbee/test/base/NeonBeeTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ protected JsonObject provideUserPrincipal(TestInfo testInfo) {
* Override this method to provide a non {@link WorkingDirectoryBuilder#standard() standard}
* {@link WorkingDirectoryBuilder}.
*
* @param testInfo The test information to be able to provide a test related WorkingDirectoryBuilder
* @param testInfo The test information to be able to provide a test related WorkingDirectoryBuilder
* @param testContext The Vert.x test context of the current test run.
* @return the WorkingDirectoryBuilder
*/
@SuppressWarnings("PMD.UnusedFormalParameter")
Expand Down Expand Up @@ -230,7 +231,7 @@ public Future<Void> undeployVerticles(Class<? extends Verticle> verticleClass) {
* Returns a pre-configured HTTP request which points to the NeonBee HTTP interface.
*
* <pre>
* path: /raw/Hodor -&gt; result: <host>:<port>/raw/Hodor
* path: /raw/Hodor -&gt; result: &lt;host&gt;:&lt;port&gt;/raw/Hodor
* </pre>
*
* @param method The HTTP method of the request
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/neonbee/test/helper/MockitoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class MockitoHelper {
*
* @param handlerPosition The position of the handler in the signature of the mocked method
* @param asyncResult The result with which the {@link Handler} is called.
* @param <T> The type of the result to handle
* @return A {@link Answer} that triggers the {@link Handler} passed to the mocked method.
*/
public static <T> Answer<Void> callHandlerAnswer(int handlerPosition, AsyncResult<T> asyncResult) {
Expand Down
Loading

0 comments on commit 9cc50e4

Please sign in to comment.