11import io.jenetics.gradle.dsl.isModule
22import 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 */
2930plugins {
3031 base
31- alias(libs.plugins.version.catalog.update)
32+ alias(libs.plugins.version.catalog.update)
3233}
3334
3435rootProject.version = JPX .VERSION
@@ -229,6 +230,9 @@ fun xlint(): String {
229230
230231val 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 }
0 commit comments