-
Notifications
You must be signed in to change notification settings - Fork 1
✨ Add compatibility with Java modules #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
345e77c
:heavy_plus_sign: add Gradle Wrapper
ryandens ca056a0
:see_no_evil: add gradle files to gitignore
ryandens da87bfc
:sparkles: add gradle build and test
ryandens 66aeea0
:sparkles: setup releasing targeting java 11
ryandens aaa96d1
:sparkles: create java 11 source set
ryandens ab7ce1b
:sparkles: use multi-release jar with module-info.java
ryandens 95dd211
:white_check_mark: test across JREs
ryandens f7643fb
:construction_worker: setup CI for Gradle
ryandens dde0354
:see_no_evil: fix gitignore for gradle wrapper
ryandens b961fe8
:bug: fix java home
ryandens 1edd3f8
:loud_sound: publish build scan
ryandens 9c62989
:fire: delete pom
ryandens 657e6f3
:bug: disable java11jar task
ryandens f4cf2a4
:rocket: release with Gradle
ryandens 12eed3c
:rocket: target maven central
ryandens b75b941
:rocket: configure GPG signing for Gradle
ryandens 6e93b85
:white_check_mark: add jacoco test report
ryandens 7430568
:sparkles: generate jacoco badge
ryandens 5c00959
:loud_sound: log percentage and upload coverage report
ryandens 48596f7
Autogenerated JaCoCo coverage badge
3ef38ec
:recycle: inline coverity escapers
ryandens 63295d8
Autogenerated JaCoCo coverage badge
d5c2806
:white_check_mark: define test suite for java 11 sources
ryandens 1a301b9
:bug: use vulnerable version of fileupload and configure DiskFileItem…
ryandens 5be0446
:heavy_plus_sign: add runtime dependency on project
ryandens c0c983a
:construction: add integration test suite
ryandens 315a2e1
:white_check_mark: add basic test app
ryandens 4c1e0ae
:white_check_mark: add module test app
ryandens 1ec348b
:bug: correct main class definition
ryandens 8353cd6
:fire: dont use applicaiton plugin for module project
ryandens 5f4dd39
:fire: dont use application plugin for hello world project
ryandens 150e0e4
:white_check_mark: test both containers
ryandens c01da23
Update test-apps/hello-world-modules/src/main/java/io/github/pixee/te…
ryandens 1b63dc6
:recycle: Move createSafeObjectInputStream to java 8 compatible class
ryandens 106398c
Autogenerated JaCoCo coverage badge
82333fe
:ok_hand: reane SafeObjectInputStream to ObjectInputStreams
ryandens ba7c98e
Autogenerated JaCoCo coverage badge
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,236 @@ | ||
| import org.javamodularity.moduleplugin.extensions.ModularityExtension | ||
|
|
||
| plugins { | ||
| `java-library` | ||
| `maven-publish` | ||
| signing | ||
| jacoco | ||
| `jvm-test-suite` | ||
| id("com.netflix.nebula.contacts") version "7.0.1" | ||
| id("com.netflix.nebula.source-jar") version "20.3.0" | ||
| id("com.netflix.nebula.javadoc-jar") version "20.3.0" | ||
| id("com.netflix.nebula.maven-publish") version "20.3.0" | ||
| id("com.netflix.nebula.publish-verification") version "20.3.0" | ||
| id("io.github.gradle-nexus.publish-plugin") version "1.3.0" | ||
| id("org.javamodularity.moduleplugin") version "1.8.12" | ||
| } | ||
|
|
||
| tasks.named<Jar>("javadocJar") { | ||
| exclude("module-info.class") | ||
| } | ||
|
|
||
| tasks.named<Jar>("sourcesJar") { | ||
| dependsOn("compileModuleInfoJava") | ||
| exclude("module-info.class") | ||
| } | ||
|
|
||
| tasks.named<JavaCompile>("compileJava") { | ||
| options.release.set(null as Int?) | ||
| } | ||
|
|
||
| configure<ModularityExtension> { | ||
| mixedJavaRelease(8) | ||
| } | ||
|
|
||
| tasks.named<JavaCompile>("compileModuleInfoJava") { | ||
| options.release.set(null as Int?) | ||
| } | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| val java11SourceSet = sourceSets.create("java11") { | ||
| java.srcDir("src/java11/main") | ||
| compileClasspath += sourceSets.main.get().output | ||
| } | ||
|
|
||
| java { | ||
| withSourcesJar() | ||
| withJavadocJar() | ||
| toolchain { | ||
| languageVersion.set(JavaLanguageVersion.of(11)) | ||
| } | ||
|
|
||
| registerFeature("java11") { | ||
| capability("io.github.pixee", "java11-support", version.toString()) | ||
| usingSourceSet(java11SourceSet) | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| api("com.martiansoftware:jsap:2.1") | ||
| api("commons-io:commons-io:2.11.0") | ||
| java11SourceSet.apiConfigurationName("commons-io:commons-io:2.11.0") | ||
| testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") | ||
| testImplementation("org.junit.jupiter:junit-jupiter-params") | ||
| testImplementation("commons-fileupload:commons-fileupload:1.3.3") | ||
| testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
| testImplementation("org.hamcrest:hamcrest-all:1.3") | ||
| testImplementation("org.mockito:mockito-core:4.0.0") | ||
| } | ||
|
|
||
| tasks.named<JavaCompile>(java11SourceSet.compileJavaTaskName) { | ||
| options.release.set(9) | ||
| } | ||
|
|
||
| tasks.jar { | ||
| into("META-INF/versions/11") { | ||
| from(java11SourceSet.output) | ||
| } | ||
| manifest.attributes( | ||
| Pair("Multi-Release", "true") | ||
| ) | ||
|
|
||
| inputs.files(tasks.named(java11SourceSet.compileJavaTaskName).map { it.outputs.files }) | ||
| } | ||
|
|
||
| tasks.named(java11SourceSet.jarTaskName) { | ||
| // disabled because we don't want to publish this separately | ||
| enabled = false | ||
| } | ||
|
|
||
| group = "io.github.pixee" | ||
| version = "1.0.7" | ||
| description = "java-security-toolkit" | ||
|
|
||
|
|
||
| extensions.getByType<nebula.plugin.contacts.ContactsExtension>().run { | ||
| addPerson( | ||
| "[email protected]", | ||
| delegateClosureOf<nebula.plugin.contacts.Contact> { | ||
| moniker("Pixee") | ||
| github("pixee") | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| val publicationName = "nebula" | ||
| signing { | ||
| if (providers.environmentVariable("CI").isPresent) { | ||
| val signingKey: String? by project | ||
| val signingPassword: String? by project | ||
| useInMemoryPgpKeys(signingKey, signingPassword) | ||
| } | ||
| sign(extensions.getByType<PublishingExtension>().publications.getByName(publicationName)) | ||
| } | ||
|
|
||
| nexusPublishing { | ||
| repositories { | ||
| sonatype { | ||
| nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) | ||
| snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| publishing { | ||
| publications { | ||
| named<MavenPublication>(publicationName) { | ||
| pom { | ||
| licenses { | ||
| license { | ||
| name.set("MIT License") | ||
| url.set("http://www.opensource.org/licenses/mit-license.php") | ||
| } | ||
| } | ||
| val scmHost = "github.com" | ||
| val scmProject = "pixee/java-security-toolkit" | ||
| val projectUrl = "https://$scmHost/$scmProject" | ||
| url.set(projectUrl) | ||
| scm { | ||
| url.set(projectUrl) | ||
| connection.set("scm:git:git@$scmHost:$scmProject") | ||
| developerConnection.set(connection) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| tasks.jacocoTestReport { | ||
| dependsOn(tasks.test) | ||
| reports { | ||
| csv.required.set(true) | ||
| } | ||
| } | ||
|
|
||
| tasks.test { | ||
| useJUnitPlatform() | ||
| finalizedBy(tasks.jacocoTestReport) | ||
| extensions.configure(org.javamodularity.moduleplugin.extensions.TestModuleOptions::class) { | ||
| // Avoid modules in tests so we can test against Java/JDK 8. | ||
| setRunOnClasspath(true) | ||
| } | ||
|
|
||
| javaLauncher.set(javaToolchains.launcherFor { | ||
| languageVersion.set(JavaLanguageVersion.of(8)) | ||
| }) | ||
| } | ||
|
|
||
| testing { | ||
| suites { | ||
| @Suppress("UnstableApiUsage") | ||
| register<JvmTestSuite>("java11Test") { | ||
| useJUnitJupiter() | ||
| dependencies { | ||
| runtimeOnly(project()) | ||
| implementation(project()) { | ||
| capabilities { | ||
| requireCapabilities("io.github.pixee:java11-support") | ||
| } | ||
| } | ||
| implementation("org.hamcrest:hamcrest-all:1.3") | ||
| implementation("org.mockito:mockito-core:4.0.0") | ||
| implementation("commons-fileupload:commons-fileupload:1.3.3") | ||
| } | ||
| } | ||
|
|
||
| register<JvmTestSuite>("integrationTest") { | ||
| useJUnitJupiter() | ||
| dependencies { | ||
| implementation("org.junit.jupiter:junit-jupiter-params") | ||
| implementation("org.testcontainers:testcontainers:1.19.0") | ||
| implementation("ch.qos.logback:logback-classic:1.2.6") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| tasks.named<Test>("java11Test") { | ||
| systemProperty("org.apache.commons.fileupload.disk.DiskFileItem.serializable", "true") | ||
| } | ||
|
|
||
| val java11Test = tasks.register<Test>("testOn11") { | ||
| useJUnitPlatform() | ||
| javaLauncher.set(javaToolchains.launcherFor { | ||
| languageVersion.set(JavaLanguageVersion.of(11)) | ||
| }) | ||
| } | ||
|
|
||
| val java17Test = tasks.register<Test>("testOn17") { | ||
| useJUnitPlatform() | ||
| javaLauncher.set(javaToolchains.launcherFor { | ||
| languageVersion.set(JavaLanguageVersion.of(17)) | ||
| }) | ||
| } | ||
|
|
||
| tasks.named<Test>("integrationTest") { | ||
| this.inputs.file(tasks.jar.map { it.archiveFile} ) | ||
| dependsOn(":test-apps:hello-world:jibDockerBuild") | ||
| dependsOn(":test-apps:hello-world-modules:jibDockerBuild") | ||
| systemProperty("securityToolkitJarPath", tasks.jar.get().archiveFile.get().asFile.relativeTo(projectDir).path) | ||
| } | ||
|
|
||
| tasks.check { | ||
| @Suppress("UnstableApiUsage") | ||
| dependsOn(java11Test, java17Test, testing.suites.named("java11Test"), testing.suites.named("integrationTest")) | ||
| } | ||
|
|
||
| tasks.compileTestJava { | ||
| extensions.configure(org.javamodularity.moduleplugin.extensions.CompileTestModuleOptions::class) { | ||
| // Avoid modules in tests so we can test against Java/JDK 8. | ||
| setCompileOnClasspath(true) | ||
| } | ||
| options.release.set(8) | ||
| } | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip | ||
| networkTimeout=10000 | ||
| validateDistributionUrl=true | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Mmmhmm. I definitely understand this. Nice!
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.
haha - just the netflix cocktail of plugins for creating a maven release that passes sonatype validation