-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(jpms): add module-info.java
descriptors
#556
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,74 @@ | ||
description = "reactive-streams" | ||
def jdkFlow = false | ||
def isJdk9OrGreater = false | ||
try { | ||
Class.forName("java.util.concurrent.Flow") | ||
jdkFlow = true | ||
isJdk9OrGreater = true | ||
} catch (ClassNotFoundException cnfe) { | ||
|
||
} | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
if (jdkFlow) | ||
srcDirs = ['src/main/java', 'src/main/java9'] | ||
else | ||
srcDirs = ['src/main/java'] | ||
srcDirs = ['src/main/java'] | ||
} | ||
} | ||
if (isJdk9OrGreater) java9 { | ||
java { | ||
srcDirs = ['src/main/java', 'src/main/java9'] | ||
} | ||
} | ||
} | ||
|
||
configurations { | ||
mrjarArtifact | ||
} | ||
Comment on lines
+23
to
25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MRJAR artifact is exported from the project, so that tests can depend on it. This is important to accurately test JPMS, otherwise Gradle will put these classes on the classpath downstream, which runs tests without modular encapsulation. |
||
|
||
jar { | ||
if (isJdk9OrGreater) into('META-INF/versions/9') { | ||
from(sourceSets.java9.output) { | ||
include '**/FlowAdapters*' | ||
include '**/module-info.class' | ||
} | ||
} | ||
Comment on lines
+28
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Amends the JAR with the |
||
|
||
bnd ('Bundle-Name': 'reactive-streams-jvm', | ||
'Bundle-Vendor': 'Reactive Streams SIG', | ||
'Bundle-Description': 'Reactive Streams API', | ||
'Bundle-DocURL': 'http://reactive-streams.org', | ||
'Bundle-Version': project.version, | ||
'Export-Package': 'org.reactivestreams.*', | ||
'Automatic-Module-Name': 'org.reactivestreams', | ||
'Bundle-SymbolicName': 'org.reactivestreams.reactive-streams' | ||
'Export-Package': 'org.reactivestreams.*,!META-INF.*', | ||
'Multi-Release': true, | ||
'Bundle-SymbolicName': 'org.reactivestreams.reactive-streams', | ||
'-fixupmessages': '^Classes found in the wrong directory: .*' | ||
Comment on lines
-27
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
) | ||
} | ||
|
||
artifacts { mrjarArtifact jar } | ||
|
||
compileJava { | ||
group = "build" | ||
description = "Compile Java 1.6 classes" | ||
} | ||
|
||
if (isJdk9OrGreater) { | ||
compileJava9Java { | ||
group = "build" | ||
description = "Compile Java 9 classes for MR JAR" | ||
|
||
sourceCompatibility = 9 | ||
targetCompatibility = 9 | ||
} | ||
Comment on lines
+54
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compile task; in this PR, the task is conditional based on whether the build-time JVM is at least Java 9. The existing build behavior is preserved in this way. In the other PR, this is addressed by Gradle Toolchains, so the build task is not conditional and is always expected to run at JDK 9 or greater during build time. |
||
|
||
tasks.register('validateModularJar', Exec) { | ||
dependsOn jar | ||
inputs.file jar.outputs.files.asPath | ||
|
||
executable = "jar" | ||
args = ['--describe-module', '--file', jar.outputs.files.asPath] | ||
} | ||
|
||
tasks.check { | ||
finalizedBy validateModularJar | ||
} | ||
Comment on lines
+63
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New task:
The expected output is an exit code of
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*************************************************** | ||
* Licensed under MIT No Attribution (SPDX: MIT-0) * | ||
***************************************************/ | ||
|
||
/** | ||
* Reactive Streams | ||
*/ | ||
module org.reactivestreams { | ||
exports org.reactivestreams; | ||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The module name matches the previous |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,23 @@ buildscript { | |
} | ||
} | ||
|
||
def sonatypeRepo = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' | ||
def sonatypeSnapshots = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
|
||
def distributionRepository = properties["distributionRepository"] ?: sonatypeRepo | ||
def snapshotsRepository = properties["snapshotsRepository"] ?: sonatypeSnapshots | ||
Comment on lines
+14
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I included a small unrelated change which allows parameterization of the deploy repositories. This will allow me to easily test integration of this JPMS support with downstream libraries. It should be completely inert to this codebase. The |
||
|
||
subprojects { | ||
apply plugin: "java-library" | ||
apply plugin: 'biz.aQute.bnd.builder' | ||
|
||
group = "org.reactivestreams" | ||
version = "1.0.4" | ||
|
||
sourceCompatibility = 1.6 | ||
targetCompatibility = 1.6 | ||
tasks.compileJava { | ||
sourceCompatibility = 1.6 | ||
targetCompatibility = 1.6 | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
configure(options) { | ||
|
@@ -53,14 +61,15 @@ subprojects { | |
"reactive-streams-tck", | ||
"reactive-streams-tck-flow", | ||
"reactive-streams-examples"]) { | ||
apply plugin: "maven" | ||
apply plugin: "signing" | ||
apply plugin: "publishing" | ||
apply plugin: "maven-publish" | ||
Comment on lines
-56
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small build cleanup because Gradle |
||
|
||
signing { | ||
sign configurations.archives | ||
required { gradle.taskGraph.hasTask(uploadArchives) } | ||
required { gradle.taskGraph.hasTask("publish") } | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
classifier "sources" | ||
from sourceSets.main.allSource | ||
|
@@ -79,41 +88,37 @@ subprojects { | |
} | ||
repositories { | ||
mavenLocal() | ||
|
||
gradle.taskGraph.whenReady { taskGraph -> | ||
if (taskGraph.hasTask("publish")) { | ||
def userProp = "sonatypeOssUsername" | ||
def passwordProp = "sonatypeOssPassword" | ||
def user = project.properties[userProp] | ||
def password = project.properties[passwordProp] | ||
|
||
if ((user == null || password == null) && distributionRepository == sonatypeRepo) { | ||
throw new InvalidUserDataException( | ||
"Cannot perform $uploadArchives.path due to missing credentials.\n" + | ||
"Run with command line args `-P$userProp=«username» -P$passwordProp=«password»` or add these properties to $gradle.gradleUserHomeDir/gradle.properties.\n") | ||
} | ||
|
||
repository(url: distributionRepository) { | ||
authentication(userName: user, password: password) | ||
} | ||
if (sonatypeSnapshots != "") { | ||
snapshotRepository(url: snapshotsRepository) { | ||
authentication(userName: user, password: password) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar, javadocJar | ||
} | ||
|
||
uploadArchives { | ||
repositories { | ||
mavenDeployer { | ||
gradle.taskGraph.whenReady { taskGraph -> | ||
if (taskGraph.hasTask(uploadArchives)) { | ||
def userProp = "sonatypeOssUsername" | ||
def passwordProp = "sonatypeOssPassword" | ||
def user = project.properties[userProp] | ||
def password = project.properties[passwordProp] | ||
|
||
if (user == null || password == null) { | ||
throw new InvalidUserDataException( | ||
"Cannot perform $uploadArchives.path due to missing credentials.\n" + | ||
"Run with command line args `-P$userProp=«username» -P$passwordProp=«password»` or add these properties to $gradle.gradleUserHomeDir/gradle.properties.\n") | ||
} | ||
|
||
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { | ||
authentication(userName: user, password: password) | ||
} | ||
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { | ||
authentication(userName: user, password: password) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.withType(Upload) { | ||
repositories.withType(MavenResolver) { | ||
it.beforeDeployment { signing.signPom(it) } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now a second source set, instead of an additional directory in the main source set. This allows a second compile task to target a different JVM bytecode level.