Skip to content

Commit

Permalink
refactor: Separated JDK management code into its own module
Browse files Browse the repository at this point in the history
Fixes #1857
  • Loading branch information
quintesse committed Jan 13, 2025
1 parent 9b5cbec commit 0f35aa5
Show file tree
Hide file tree
Showing 66 changed files with 2,843 additions and 1,590 deletions.
184 changes: 96 additions & 88 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,85 @@ plugins {
id 'maven-publish'
}

javadoc {
options.encoding = 'UTF-8'
//remove this to see all the missing tags/parameters.
options.addStringOption('Xdoclint:none', '-quiet')
}
allprojects {
//apply plugin: "java"
apply plugin: "com.diffplug.spotless"

sourceCompatibility = '8'
targetCompatibility = '8'

spotless {
lineEndings 'UNIX'
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
targetExclude 'CONTRIBUTORS.md', 'src/main/scripts/container/README.md', 'build/**/*', 'out/**/*'
// all-contributor bot adds non-indented code
trimTrailingWhitespace()
indentWithTabs(4) // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
importOrder 'java', 'javax', 'org', 'com', 'dev.jbang', ''
removeUnusedImports()
eclipse().configFile new File(rootProject.projectDir, "misc/eclipse_formatting_nowrap.xml")
targetExclude 'build/**/*'
}
format 'xml', {
targetExclude 'build/test-results', fileTree('.idea')
target '**/*.xml', '**/*.nuspec'
}
}

repositories {
mavenCentral()
//maven { url 'https://jitpack.io' }
}
javadoc {
options.encoding = 'UTF-8'
//remove this to see all the missing tags/parameters.
options.addStringOption('Xdoclint:none', '-quiet')
}

repositories {
mavenCentral()
//maven { url 'https://jitpack.io' }
}

java {
withJavadocJar()
withSourcesJar()
java {
withJavadocJar()
withSourcesJar()
}

test {
useJUnitPlatform()
jvmArgs = [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED"
]
//testLogging.showStandardStreams = true

/*testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}*/
//timeout.set(Duration.ofSeconds(60))

jacoco {
enabled = false
}
}

jacoco {
toolVersion = '0.8.7'
}

jacocoTestReport {
afterEvaluate {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}

reports {
html.required = true
xml.required = true
csv.required = false
}
}
}

publishing {
Expand Down Expand Up @@ -77,6 +142,22 @@ publishing {
url = layout.buildDirectory.dir('staging-deploy')
}
}

// to enable reproducible builds
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked"
}

compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked"
}
}

sourceSets {
Expand All @@ -90,6 +171,8 @@ sourceSets {
sourceSets.main.compileClasspath += sourceSets.java9.output.classesDirs;

dependencies {
implementation project(':jdkmanager')

implementation 'com.offbytwo:docopt:0.6.0.20150202'

implementation 'org.apache.commons:commons-text:1.11.0'
Expand All @@ -110,6 +193,7 @@ dependencies {
runtimeOnly "eu.maveniverse.maven.mima.runtime:standalone-static:2.4.20"

testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.1"
testImplementation project(':jdkmanager')
testImplementation "org.junit.jupiter:junit-jupiter:5.10.1"
testImplementation "com.github.stefanbirkner:system-rules:1.17.2"
testImplementation "org.hamcrest:hamcrest-library:2.2"
Expand All @@ -126,12 +210,6 @@ buildConfig {
buildConfigField('String', 'VERSION', provider { "\"${project.version}\"" })
}

// to enable reproducible builds
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

sonarqube {
properties {
property "sonar.projectKey", "jbangdev_jbang"
Expand All @@ -140,28 +218,6 @@ sonarqube {
}
}

spotless {
lineEndings 'UNIX'
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
targetExclude 'CONTRIBUTORS.md', 'src/main/scripts/container/README.md', 'build/**/*', 'out/**/*'
// all-contributor bot adds non-indented code
trimTrailingWhitespace()
indentWithTabs(4) // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
importOrder 'java', 'javax', 'org', 'com', 'dev.jbang', ''
removeUnusedImports()
eclipse().configFile "misc/eclipse_formatting_nowrap.xml"
targetExclude 'build/**/*'
}
format 'xml', {
targetExclude 'build/test-results', fileTree('.idea')
target '**/*.xml', '**/*.nuspec'
}
}

task versionTxt() {
doLast {
new File(project.buildDir, "tmp/version.txt").text = project.version
Expand Down Expand Up @@ -218,16 +274,6 @@ jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked"
}

compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked"
}

compileJava9Java {
sourceCompatibility = 9
targetCompatibility = 9
Expand All @@ -251,42 +297,6 @@ shadowJar {
archiveFileName = "${archiveBaseName.get()}.${archiveExtension.get()}"
}

test {
useJUnitPlatform()
jvmArgs = [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED"
]
//testLogging.showStandardStreams = true

/*testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}*/
//timeout.set(Duration.ofSeconds(60))

jacoco {
enabled = false
}
}

jacoco {
toolVersion = '0.8.7'
}

jacocoTestReport {
afterEvaluate {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}

reports {
html.required = true
xml.required = true
csv.required = false
}
}


task karateExecute(type: JavaExec) {
classpath = sourceSets.test.runtimeClasspath
mainClass = System.properties.getProperty('mainClass')
Expand Down Expand Up @@ -435,5 +445,3 @@ tasks.named("spotlessXml").configure { dependsOn("chocolatey") }
tasks.named("spotlessXml").configure { dependsOn("copyITests") }

group = "dev.jbang"
sourceCompatibility = '8'
targetCompatibility = '8'
22 changes: 22 additions & 0 deletions jdkmanager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.classpath
.project
.vscode
.settings
target
.idea
*.iml
/build
.gradle
.factorypath
bin
homebrew-tap
RESULTS
*.db
jbang-action
out
node_modules
package-lock.json
*.jfr
itests/hello.java
*.class
CHANGELOG.md
23 changes: 23 additions & 0 deletions jdkmanager/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id 'java'
}

group = 'dev.jbang.jvm'
version = parent.version

sourceCompatibility = '8'
targetCompatibility = '8'

dependencies {
implementation 'org.apache.commons:commons-compress:1.26.2'
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
implementation 'org.apache.httpcomponents:httpclient-cache:4.5.14'
implementation 'com.google.code.gson:gson:2.11.0'

implementation "org.slf4j:slf4j-nop:1.7.30"
implementation "org.slf4j:jcl-over-slf4j:1.7.30"
implementation "org.jspecify:jspecify:1.0.0"

testImplementation platform('org.junit:junit-bom:5.10.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
Loading

0 comments on commit 0f35aa5

Please sign in to comment.