Skip to content
Merged
Show file tree
Hide file tree
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 Sep 21, 2023
ca056a0
:see_no_evil: add gradle files to gitignore
ryandens Sep 21, 2023
da87bfc
:sparkles: add gradle build and test
ryandens Sep 21, 2023
66aeea0
:sparkles: setup releasing targeting java 11
ryandens Sep 21, 2023
aaa96d1
:sparkles: create java 11 source set
ryandens Sep 26, 2023
ab7ce1b
:sparkles: use multi-release jar with module-info.java
ryandens Sep 26, 2023
95dd211
:white_check_mark: test across JREs
ryandens Sep 26, 2023
f7643fb
:construction_worker: setup CI for Gradle
ryandens Sep 26, 2023
dde0354
:see_no_evil: fix gitignore for gradle wrapper
ryandens Sep 26, 2023
b961fe8
:bug: fix java home
ryandens Sep 26, 2023
1edd3f8
:loud_sound: publish build scan
ryandens Sep 26, 2023
9c62989
:fire: delete pom
ryandens Sep 26, 2023
657e6f3
:bug: disable java11jar task
ryandens Sep 26, 2023
f4cf2a4
:rocket: release with Gradle
ryandens Sep 26, 2023
12eed3c
:rocket: target maven central
ryandens Sep 26, 2023
b75b941
:rocket: configure GPG signing for Gradle
ryandens Sep 26, 2023
6e93b85
:white_check_mark: add jacoco test report
ryandens Sep 26, 2023
7430568
:sparkles: generate jacoco badge
ryandens Sep 26, 2023
5c00959
:loud_sound: log percentage and upload coverage report
ryandens Sep 26, 2023
48596f7
Autogenerated JaCoCo coverage badge
Sep 26, 2023
3ef38ec
:recycle: inline coverity escapers
ryandens Sep 26, 2023
63295d8
Autogenerated JaCoCo coverage badge
Sep 26, 2023
d5c2806
:white_check_mark: define test suite for java 11 sources
ryandens Sep 26, 2023
1a301b9
:bug: use vulnerable version of fileupload and configure DiskFileItem…
ryandens Sep 26, 2023
5be0446
:heavy_plus_sign: add runtime dependency on project
ryandens Sep 26, 2023
c0c983a
:construction: add integration test suite
ryandens Sep 26, 2023
315a2e1
:white_check_mark: add basic test app
ryandens Sep 27, 2023
4c1e0ae
:white_check_mark: add module test app
ryandens Sep 28, 2023
1ec348b
:bug: correct main class definition
ryandens Sep 28, 2023
8353cd6
:fire: dont use applicaiton plugin for module project
ryandens Sep 28, 2023
5f4dd39
:fire: dont use application plugin for hello world project
ryandens Sep 28, 2023
150e0e4
:white_check_mark: test both containers
ryandens Sep 28, 2023
c01da23
Update test-apps/hello-world-modules/src/main/java/io/github/pixee/te…
ryandens Sep 28, 2023
1b63dc6
:recycle: Move createSafeObjectInputStream to java 8 compatible class
ryandens Sep 28, 2023
106398c
Autogenerated JaCoCo coverage badge
Sep 28, 2023
82333fe
:ok_hand: reane SafeObjectInputStream to ObjectInputStreams
ryandens Sep 28, 2023
ba7c98e
Autogenerated JaCoCo coverage badge
Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/badges/branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 15 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: "Set up JDK 11"
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Set up JDKs 8, 11, 17
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
distribution: 'temurin'
java-version: |
8
17
11

- name: "Build with Maven"
run: mvn -Pci verify
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Execute Gradle build
run: ./gradlew build

- name: "Generate Coverage Badge"
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv

- name: "Log coverage percentage"
run: |
Expand All @@ -40,4 +47,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: jacoco-report
path: target/site/jacoco/
path: build/reports/jacoco/test/html/
47 changes: 19 additions & 28 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,34 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v2

- name: "Setup Java"
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Set up JDKs 8, 11, 17
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
distribution: 'temurin'
java-version: |
8
17
11

- name: "Build with Maven"
run: mvn -Pci verify
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Execute Gradle build
run: ./gradlew build

- name: "Create release"
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
target/java-security-*.jar
build/libs/java-security-*.jar

- name: "Publish to Maven Central"
run: |
mvn \
-Prelease \
-X \
--no-transfer-progress \
--batch-mode \
clean \
deploy
run: ./gradlew publish
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Compiled class file
*.class

build
.gradle
# Log file
*.log

Expand All @@ -12,6 +13,7 @@

# Package Files #
*.jar
!gradle/wrapper/gradle-wrapper.jar
*.war
*.nar
*.ear
Expand Down
236 changes: 236 additions & 0 deletions build.gradle.kts
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"
Copy link
Contributor

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!

Copy link
Member Author

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

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 added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
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
Loading