Skip to content

Commit 97af57a

Browse files
committed
Upgrade publishing scripts.
Signed-off-by: Franz Wilhelmstötter <franz.wilhelmstoetter@gmail.com>
1 parent d7bd5af commit 97af57a

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

build.gradle.kts

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io.jenetics.gradle.dsl.isModule
22
import io.jenetics.gradle.dsl.moduleName
3+
import org.apache.tools.ant.filters.ReplaceTokens
34

45
/*
56
* Java GPX Library (@__identifier__@).
@@ -9,7 +10,7 @@ import io.jenetics.gradle.dsl.moduleName
910
* you may not use this file except in compliance with the License.
1011
* You may obtain a copy of the License at
1112
*
12-
* http://www.apache.org/licenses/LICENSE-2.0
13+
* http://www.apache.org/licenses/LICENSE-2.0
1314
*
1415
* Unless required by applicable law or agreed to in writing, software
1516
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,7 +19,7 @@ import io.jenetics.gradle.dsl.moduleName
1819
* limitations under the License.
1920
*
2021
* Author:
21-
* Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
22+
* Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
2223
*/
2324

2425
/**
@@ -28,7 +29,7 @@ import io.jenetics.gradle.dsl.moduleName
2829
*/
2930
plugins {
3031
base
31-
alias(libs.plugins.version.catalog.update)
32+
alias(libs.plugins.version.catalog.update)
3233
}
3334

3435
rootProject.version = JPX.VERSION
@@ -229,6 +230,9 @@ fun xlint(): String {
229230

230231
val identifier = "${JPX.ID}-${JPX.VERSION}"
231232

233+
/**
234+
* Setup of the Maven publishing.
235+
*/
232236
/**
233237
* Setup of the Maven publishing.
234238
*/
@@ -240,26 +244,29 @@ fun setupPublishing(project: Project) {
240244

241245
project.tasks.named<Jar>("sourcesJar") {
242246
filter(
243-
org.apache.tools.ant.filters.ReplaceTokens::class, "tokens" to mapOf(
244-
"__identifier__" to identifier,
245-
"__year__" to Env.COPYRIGHT_YEAR
246-
)
247+
ReplaceTokens::class, "tokens" to mapOf(
248+
"__identifier__" to identifier,
249+
"__year__" to Env.COPYRIGHT_YEAR
250+
)
247251
)
248252
}
249253

250254
project.tasks.named<Jar>("javadocJar") {
251255
filter(
252-
org.apache.tools.ant.filters.ReplaceTokens::class, "tokens" to mapOf(
253-
"__identifier__" to identifier,
254-
"__year__" to Env.COPYRIGHT_YEAR
255-
)
256+
ReplaceTokens::class, "tokens" to mapOf(
257+
"__identifier__" to identifier,
258+
"__year__" to Env.COPYRIGHT_YEAR
259+
)
256260
)
257261
}
258262

259263
project.configure<PublishingExtension> {
260264
publications {
261265
create<MavenPublication>("mavenJava") {
262-
artifactId = JPX.ID
266+
suppressPomMetadataWarningsFor("testFixturesApiElements")
267+
suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
268+
269+
artifactId = project.name
263270
from(project.components["java"])
264271
versionMapping {
265272
usage("java-api") {
@@ -299,24 +306,23 @@ fun setupPublishing(project: Project) {
299306
}
300307
repositories {
301308
maven {
302-
url = if (version.toString().endsWith("SNAPSHOT")) {
303-
uri(Maven.SNAPSHOT_URL)
304-
} else {
305-
uri(Maven.RELEASE_URL)
306-
}
309+
url = if (version.toString().endsWith("SNAPSHOT"))
310+
uri(layout.buildDirectory.dir("repos/snapshots"))
311+
else
312+
uri(layout.buildDirectory.dir("repos/releases"))
313+
}
314+
}
307315

308-
credentials {
309-
username = if (extra.properties["nexus_username"] != null) {
310-
extra.properties["nexus_username"] as String
311-
} else {
312-
"nexus_username"
313-
}
314-
password = if (extra.properties["nexus_password"] != null) {
315-
extra.properties["nexus_password"] as String
316-
} else {
317-
"nexus_password"
318-
}
319-
}
316+
// Exclude test fixtures from publication, as we use them only internally
317+
plugins.withId("org.gradle.java-test-fixtures") {
318+
val component = components["java"] as AdhocComponentWithVariants
319+
component.withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
320+
component.withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }
321+
322+
// Workaround to not publish test fixtures sources added by com.vanniktech.maven.publish plugin
323+
// TODO: Remove as soon as https://github.com/vanniktech/gradle-maven-publish-plugin/issues/779 closed
324+
afterEvaluate {
325+
component.withVariantsFromConfiguration(configurations["testFixturesSourcesElements"]) { skip() }
320326
}
321327
}
322328
}

buildSrc/resources/javadoc/java.se/element-list

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ java.io
33
java.lang
44
java.lang.annotation
55
java.lang.constant
6+
java.lang.foreign
67
java.lang.invoke
78
java.lang.module
89
java.lang.ref
@@ -221,12 +222,9 @@ module:jdk.hotspot.agent
221222
module:jdk.httpserver
222223
com.sun.net.httpserver
223224
com.sun.net.httpserver.spi
224-
module:jdk.incubator.foreign
225-
jdk.incubator.foreign
226225
module:jdk.incubator.vector
227226
jdk.incubator.vector
228227
module:jdk.jartool
229-
com.sun.jarsigner
230228
jdk.security.jarsigner
231229
module:jdk.javadoc
232230
jdk.javadoc.doclet

0 commit comments

Comments
 (0)