|
1 | | -plugins { |
2 | | - id 'java-library' |
3 | | - id 'io.toolebox.git-versioner' version '1.6.7' |
4 | | - id 'com.diffplug.spotless' version '7.2.1' |
5 | | - id 'maven-publish' |
6 | | - id 'org.jreleaser' version '1.21.0' |
7 | | -} |
8 | | - |
9 | | -group = 'dev.jbang' |
10 | | - |
11 | | -def javaVersion = System.getProperty('java.version') |
12 | | -def majorVersion = javaVersion.split('\\.')[0].toInteger() |
13 | | -if (majorVersion < 11) { |
14 | | - throw new GradleException(""" |
15 | | - ⚠️ This build requires Java 11 or newer but you're using Java ${javaVersion} |
16 | | - Please use JAVA_HOME with Java 11 or newer to run this build. |
17 | | - Current JAVA_HOME: ${System.getProperty('java.home')}. |
18 | | - If you have jbang installed, you can run it with: |
19 | | - eval \$(jbang jdk java-env 11+) |
20 | | - """.stripIndent()) |
21 | | -} |
22 | | - |
23 | | -javadoc { |
24 | | - options.encoding = 'UTF-8' |
25 | | - //remove this to see all the missing tags/parameters. |
26 | | - options.addStringOption('Xdoclint:none', '-quiet') |
27 | | -} |
28 | | - |
29 | | -repositories { |
30 | | - mavenCentral() |
31 | | -} |
32 | | - |
33 | | -java { |
34 | | - withJavadocJar() |
35 | | - withSourcesJar() |
36 | | -} |
37 | | - |
38 | | -compileJava { |
39 | | - options.encoding = 'UTF-8' |
40 | | - options.release = 8; |
41 | | -} |
42 | | - |
43 | | -versioner { |
44 | | - pattern { |
45 | | - pattern = "%M.%m.%p(.%c-SNAPSHOT)" |
46 | | - } |
47 | | - git { |
48 | | - authentication { |
49 | | - https { |
50 | | - token = project.hasProperty('github_token') ? getProperty('github_token') : "unknown_github_token" |
51 | | - } |
52 | | - } |
53 | | - } |
54 | | -} |
55 | | - |
56 | | -dependencies { |
57 | | - implementation 'org.apache.commons:commons-compress:1.28.0' |
58 | | - implementation 'com.google.code.gson:gson:2.13.2' |
59 | | - implementation 'org.jspecify:jspecify:1.0.0' |
60 | | - |
61 | | - implementation('org.apache.httpcomponents.client5:httpclient5:5.6') { |
62 | | - // Optional: Only needed if using DefaultRemoteAccessProvider |
63 | | - } |
64 | | - implementation('org.apache.httpcomponents.client5:httpclient5-cache:5.6') { |
65 | | - // Optional: Only needed if using DefaultRemoteAccessProvider |
66 | | - } |
67 | | - |
68 | | - testImplementation platform('org.junit:junit-bom:6.0.1') |
69 | | - testImplementation 'org.junit.jupiter:junit-jupiter' |
70 | | - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' |
71 | | - testImplementation "org.hamcrest:hamcrest-library:3.0" |
72 | | - testImplementation "uk.org.webcompere:system-stubs-jupiter:2.1.8" |
73 | | - testImplementation "uk.org.webcompere:system-stubs-core:2.1.8" |
74 | | -} |
75 | | - |
76 | | -tasks.withType(AbstractArchiveTask) { |
77 | | - preserveFileTimestamps = false |
78 | | - reproducibleFileOrder = true |
79 | | -} |
80 | | - |
81 | | -spotless { |
82 | | - format 'misc', { |
83 | | - target '**/*.gradle', '**/*.md', '**/.gitignore' |
84 | | - targetExclude 'build/**/*', 'out/**/*' |
85 | | - trimTrailingWhitespace() |
86 | | - leadingSpacesToTabs() |
87 | | - endWithNewline() |
88 | | - } |
89 | | - java { |
90 | | - importOrder 'java', 'javax', 'org', 'com', 'dev.jbang', '' |
91 | | - removeUnusedImports() |
92 | | - eclipse().configFile "misc/eclipse_formatting_nowrap.xml" |
93 | | - targetExclude 'build/**/*' |
94 | | - } |
95 | | - format 'xml', { |
96 | | - targetExclude 'build/test-results', fileTree('.idea') |
97 | | - target '**/*.xml', '**/*.nuspec' |
98 | | - } |
99 | | -} |
100 | | - |
101 | | -test { |
102 | | - useJUnitPlatform() |
103 | | - jvmArgs = [ |
104 | | - "--add-opens", "java.base/java.lang=ALL-UNNAMED", |
105 | | - "--add-opens", "java.base/java.util=ALL-UNNAMED" |
106 | | - ] |
107 | | -} |
108 | | - |
109 | | -publishing { |
110 | | - publications { |
111 | | - maven(MavenPublication) { |
112 | | - groupId = 'dev.jbang' |
113 | | - artifactId = 'devkitman' |
114 | | - |
115 | | - from components.java |
116 | | - |
117 | | - pom { |
118 | | - name = 'JBang JDK Manager' |
119 | | - description = 'Library for managing JDK installations' |
120 | | - url = 'https://github.com/jbangdev/jbang-devkitman' |
121 | | - inceptionYear = '2025' |
122 | | - licenses { |
123 | | - license { |
124 | | - name = 'MIT' |
125 | | - url = 'https://github.com/jbangdev/jbang-devkitman/blob/main/LICENSE' |
126 | | - } |
127 | | - } |
128 | | - developers { |
129 | | - developer { |
130 | | - id = 'maxandersen' |
131 | | - name = 'Max Rydahl Andersen' |
132 | | - } |
133 | | - developer { |
134 | | - id = 'quintesse' |
135 | | - name = 'Tako Schotanus' |
136 | | - } |
137 | | - } |
138 | | - scm { |
139 | | - connection = 'scm:git:https://github.com/jbangdev/jbang-devkitman' |
140 | | - developerConnection = 'scm:git:https://github.com/jbangdev/jbang-devkitman' |
141 | | - url = 'http://github.com/jbangdev/jbang-devkitman' |
142 | | - } |
143 | | - |
144 | | - // Mark Apache HttpClient dependencies as optional |
145 | | - withXml { |
146 | | - def dependenciesNode = asNode().dependencies[0] |
147 | | - dependenciesNode.dependency.each { dep -> |
148 | | - def groupId = dep.groupId[0].text() |
149 | | - def artifactId = dep.artifactId[0].text() |
150 | | - if (groupId == 'org.apache.httpcomponents.client5' && |
151 | | - (artifactId == 'httpclient5' || artifactId == 'httpclient5-cache')) { |
152 | | - dep.appendNode('optional', true) |
153 | | - } |
154 | | - } |
155 | | - } |
156 | | - } |
157 | | - } |
158 | | - } |
159 | | - |
160 | | - repositories { |
161 | | - maven { |
162 | | - url = layout.buildDirectory.dir('staging-deploy') |
163 | | - } |
164 | | - } |
165 | | -} |
166 | | - |
167 | | -jreleaser { |
168 | | - configFile = file('jreleaser.yml') |
169 | | -} |
| 1 | +plugins { |
| 2 | + id 'java-library' |
| 3 | + id 'io.toolebox.git-versioner' version '1.6.7' |
| 4 | + id 'com.diffplug.spotless' version '7.2.1' |
| 5 | + id 'maven-publish' |
| 6 | + id 'org.jreleaser' version '1.21.0' |
| 7 | +} |
| 8 | + |
| 9 | +group = 'dev.jbang' |
| 10 | + |
| 11 | +def javaVersion = System.getProperty('java.version') |
| 12 | +def majorVersion = javaVersion.split('\\.')[0].toInteger() |
| 13 | +if (majorVersion < 11) { |
| 14 | + throw new GradleException(""" |
| 15 | + ⚠️ This build requires Java 11 or newer but you're using Java ${javaVersion} |
| 16 | + Please use JAVA_HOME with Java 11 or newer to run this build. |
| 17 | + Current JAVA_HOME: ${System.getProperty('java.home')}. |
| 18 | + If you have jbang installed, you can run it with: |
| 19 | + eval \$(jbang jdk java-env 11+) |
| 20 | + """.stripIndent()) |
| 21 | +} |
| 22 | + |
| 23 | +javadoc { |
| 24 | + options.encoding = 'UTF-8' |
| 25 | + //remove this to see all the missing tags/parameters. |
| 26 | + options.addStringOption('Xdoclint:none', '-quiet') |
| 27 | +} |
| 28 | + |
| 29 | +repositories { |
| 30 | + mavenCentral() |
| 31 | +} |
| 32 | + |
| 33 | +java { |
| 34 | + withJavadocJar() |
| 35 | + withSourcesJar() |
| 36 | +} |
| 37 | + |
| 38 | +compileJava { |
| 39 | + options.encoding = 'UTF-8' |
| 40 | + options.release = 8; |
| 41 | +} |
| 42 | + |
| 43 | +versioner { |
| 44 | + pattern { |
| 45 | + pattern = "%M.%m.%p(.%c-SNAPSHOT)" |
| 46 | + } |
| 47 | + git { |
| 48 | + authentication { |
| 49 | + https { |
| 50 | + token = project.hasProperty('github_token') ? getProperty('github_token') : "unknown_github_token" |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +dependencies { |
| 57 | + implementation 'org.apache.commons:commons-compress:1.28.0' |
| 58 | + implementation 'com.google.code.gson:gson:2.13.2' |
| 59 | + implementation 'org.jspecify:jspecify:1.0.0' |
| 60 | + |
| 61 | + implementation('org.apache.httpcomponents.client5:httpclient5:5.6') { |
| 62 | + // Optional: Only needed if using DefaultRemoteAccessProvider |
| 63 | + } |
| 64 | + implementation('org.apache.httpcomponents.client5:httpclient5-cache:5.6') { |
| 65 | + // Optional: Only needed if using DefaultRemoteAccessProvider |
| 66 | + } |
| 67 | + |
| 68 | + testImplementation platform('org.junit:junit-bom:6.0.1') |
| 69 | + testImplementation 'org.junit.jupiter:junit-jupiter' |
| 70 | + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' |
| 71 | + testImplementation "org.hamcrest:hamcrest-library:3.0" |
| 72 | + testImplementation "uk.org.webcompere:system-stubs-jupiter:2.1.8" |
| 73 | + testImplementation "uk.org.webcompere:system-stubs-core:2.1.8" |
| 74 | +} |
| 75 | + |
| 76 | +tasks.withType(AbstractArchiveTask) { |
| 77 | + preserveFileTimestamps = false |
| 78 | + reproducibleFileOrder = true |
| 79 | +} |
| 80 | + |
| 81 | +spotless { |
| 82 | + format 'misc', { |
| 83 | + target '**/*.gradle', '**/*.md', '**/.gitignore' |
| 84 | + targetExclude 'build/**/*', 'out/**/*' |
| 85 | + trimTrailingWhitespace() |
| 86 | + leadingSpacesToTabs() |
| 87 | + endWithNewline() |
| 88 | + } |
| 89 | + java { |
| 90 | + importOrder 'java', 'javax', 'org', 'com', 'dev.jbang', '' |
| 91 | + removeUnusedImports() |
| 92 | + eclipse().configFile "misc/eclipse_formatting_nowrap.xml" |
| 93 | + targetExclude 'build/**/*' |
| 94 | + } |
| 95 | + format 'xml', { |
| 96 | + targetExclude 'build/test-results', fileTree('.idea') |
| 97 | + target '**/*.xml', '**/*.nuspec' |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +test { |
| 102 | + useJUnitPlatform() |
| 103 | + jvmArgs = [ |
| 104 | + "--add-opens", "java.base/java.lang=ALL-UNNAMED", |
| 105 | + "--add-opens", "java.base/java.util=ALL-UNNAMED" |
| 106 | + ] |
| 107 | +} |
| 108 | + |
| 109 | +publishing { |
| 110 | + publications { |
| 111 | + maven(MavenPublication) { |
| 112 | + groupId = 'dev.jbang' |
| 113 | + artifactId = 'devkitman' |
| 114 | + |
| 115 | + from components.java |
| 116 | + |
| 117 | + pom { |
| 118 | + name = 'JBang JDK Manager' |
| 119 | + description = 'Library for managing JDK installations' |
| 120 | + url = 'https://github.com/jbangdev/jbang-devkitman' |
| 121 | + inceptionYear = '2025' |
| 122 | + licenses { |
| 123 | + license { |
| 124 | + name = 'MIT' |
| 125 | + url = 'https://github.com/jbangdev/jbang-devkitman/blob/main/LICENSE' |
| 126 | + } |
| 127 | + } |
| 128 | + developers { |
| 129 | + developer { |
| 130 | + id = 'maxandersen' |
| 131 | + name = 'Max Rydahl Andersen' |
| 132 | + } |
| 133 | + developer { |
| 134 | + id = 'quintesse' |
| 135 | + name = 'Tako Schotanus' |
| 136 | + } |
| 137 | + } |
| 138 | + scm { |
| 139 | + connection = 'scm:git:https://github.com/jbangdev/jbang-devkitman' |
| 140 | + developerConnection = 'scm:git:https://github.com/jbangdev/jbang-devkitman' |
| 141 | + url = 'http://github.com/jbangdev/jbang-devkitman' |
| 142 | + } |
| 143 | + |
| 144 | + // Mark Apache HttpClient dependencies as optional |
| 145 | + withXml { |
| 146 | + def dependenciesNode = asNode().dependencies[0] |
| 147 | + dependenciesNode.dependency.each { dep -> |
| 148 | + def groupId = dep.groupId[0].text() |
| 149 | + def artifactId = dep.artifactId[0].text() |
| 150 | + if (groupId == 'org.apache.httpcomponents.client5' && |
| 151 | + (artifactId == 'httpclient5' || artifactId == 'httpclient5-cache')) { |
| 152 | + dep.appendNode('optional', true) |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + } |
| 157 | + } |
| 158 | + } |
| 159 | + |
| 160 | + repositories { |
| 161 | + maven { |
| 162 | + url = layout.buildDirectory.dir('staging-deploy') |
| 163 | + } |
| 164 | + } |
| 165 | +} |
| 166 | + |
| 167 | +jreleaser { |
| 168 | + configFile = file('jreleaser.yml') |
| 169 | +} |
0 commit comments