You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2023/11/27 17:54:44 UTC

(sis) 02/02: Create a "sis.library-conventions" with some common configuration for Gradle build.

This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit af3440719f82877ebc51684d79e386379c644f01
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Mon Nov 27 14:04:17 2023 +0100

    Create a "sis.library-conventions" with some common configuration for Gradle build.
---
 buildSrc/build.gradle.kts                          |  1 +
 .../main/kotlin/sis.library-conventions.gradle.kts | 68 ++++++++++++++++++++++
 endorsed/build.gradle.kts                          | 27 +--------
 incubator/build.gradle.kts                         | 24 +-------
 optional/build.gradle.kts                          | 25 +-------
 5 files changed, 76 insertions(+), 69 deletions(-)

diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index cfbc70ea94..8b74d433bc 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -16,6 +16,7 @@
  */
 plugins {
     `java-gradle-plugin`
+    `kotlin-dsl`
 }
 
 gradlePlugin {
diff --git a/buildSrc/src/main/kotlin/sis.library-conventions.gradle.kts b/buildSrc/src/main/kotlin/sis.library-conventions.gradle.kts
new file mode 100644
index 0000000000..140c601648
--- /dev/null
+++ b/buildSrc/src/main/kotlin/sis.library-conventions.gradle.kts
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+group = "org.apache.sis"
+version = "2.0-SNAPSHOT"
+
+/*
+ * "org.apache.sis.buildtools" is a custom Gradle plugin for building a project with Module Source Hierarchy
+ * as specified in https://docs.oracle.com/en/java/javase/21/docs/specs/man/javac.html#directory-hierarchies
+ * The expected hierarchy is:
+ *
+ *   endorsed
+ *     ├─ build
+ *     └─ src
+ *         ├─ org.apache.sis.metadata
+ *         │    ├─ main
+ *         │    │   ├─ module-info.java
+ *         │    │   └─ org/apache/sis/metadata/…
+ *         │    └─ test
+ *         │        └─ org/apache/sis/metadata/…
+ *         ├─ org.apache.sis.referencing
+ *         │    ├─ main
+ *         │    │   ├─ module-info.java
+ *         │    │   └─ org/apache/sis/referencing/…
+ *         │    └─ test
+ *         │        └─ org/apache/sis/referencing/…
+ *         └─ etc.
+ */
+plugins {
+    `java-library`
+    `maven-publish`
+    signing
+}
+
+/*
+ * Configuration of the repositories where to deploy artifacts.
+ */
+publishing {
+    repositories {
+        maven {
+            name = "Apache"
+            url = uri(if (version.toString().endsWith("SNAPSHOT"))
+                      "https://repository.apache.org/content/repositories/snapshots" else
+                      "https://repository.apache.org/service/local/staging/deploy/maven2")
+            credentials {
+                val asfNexusUsername = providers.gradleProperty("asfNexusUsername")
+                val asfNexusPassword = providers.gradleProperty("asfNexusPassword")
+                if (asfNexusUsername.isPresent() && asfNexusPassword.isPresent()) {
+                    username = asfNexusUsername.get()
+                    password = asfNexusPassword.get()
+                }
+            }
+        }
+    }
+}
diff --git a/endorsed/build.gradle.kts b/endorsed/build.gradle.kts
index 828fc2b9d5..39ec0363db 100644
--- a/endorsed/build.gradle.kts
+++ b/endorsed/build.gradle.kts
@@ -14,12 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-group = "org.apache.sis"
-version = "2.0-SNAPSHOT"
 
 /*
- * "org.apache.sis.buildtools" is a custom Gradle plugin for building a project with Module Source Hierarchy
- * as specified in https://docs.oracle.com/en/java/javase/20/docs/specs/man/javac.html#directory-hierarchies
+ * This project uses a custom Gradle plugin for building a project with Module Source Hierarchy as specified
+ * in https://docs.oracle.com/en/java/javase/21/docs/specs/man/javac.html#directory-hierarchies documentation.
  * The expected hierarchy is:
  *
  *   endorsed
@@ -40,9 +38,7 @@ version = "2.0-SNAPSHOT"
  *         └─ etc.
  */
 plugins {
-    `java-library`
-    `maven-publish`
-    signing
+    id("sis.library-conventions")
     id("org.apache.sis.buildtools")
 }
 
@@ -445,23 +441,6 @@ publishing {
             }
         }
     }
-    /* Following block is currently repeated in all sub-projects. */
-    repositories {
-        maven {
-            name = "Apache"
-            url = uri(if (version.toString().endsWith("SNAPSHOT"))
-                      "https://repository.apache.org/content/repositories/snapshots" else
-                      "https://repository.apache.org/service/local/staging/deploy/maven2")
-            credentials {
-                val asfNexusUsername = providers.gradleProperty("asfNexusUsername")
-                val asfNexusPassword = providers.gradleProperty("asfNexusPassword")
-                if (asfNexusUsername.isPresent() && asfNexusPassword.isPresent()) {
-                    username = asfNexusUsername.get()
-                    password = asfNexusPassword.get()
-                }
-            }
-        }
-    }
 }
 
 signing {
diff --git a/incubator/build.gradle.kts b/incubator/build.gradle.kts
index dfc09811ba..cf4ec04008 100644
--- a/incubator/build.gradle.kts
+++ b/incubator/build.gradle.kts
@@ -14,16 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-group = "org.apache.sis"
-version = "2.0-SNAPSHOT"
 
 /*
- * "org.apache.sis.buildtools" is a custom Gradle plugin for building a project with Module Source Hierarchy.
+ * This project uses a custom Gradle plugin for building a project with Module Source Hierarchy.
  * See the Gradle build script in the `endorsed` directory for more information.
  */
 plugins {
-    `java-library`
-    `maven-publish`     // For local deployment only. Not to be published on Maven Central.
+    id("sis.library-conventions")
     id("org.apache.sis.buildtools")
     antlr
 }
@@ -152,21 +149,4 @@ publishing {
             }
         }
     }
-    /* Following block is currently repeated in all sub-projects. */
-    repositories {
-        maven {
-            name = "Apache"
-            url = uri(if (version.toString().endsWith("SNAPSHOT"))
-                      "https://repository.apache.org/content/repositories/snapshots" else
-                      "https://repository.apache.org/service/local/staging/deploy/maven2")
-            credentials {
-                val asfNexusUsername = providers.gradleProperty("asfNexusUsername")
-                val asfNexusPassword = providers.gradleProperty("asfNexusPassword")
-                if (asfNexusUsername.isPresent() && asfNexusPassword.isPresent()) {
-                    username = asfNexusUsername.get()
-                    password = asfNexusPassword.get()
-                }
-            }
-        }
-    }
 }
diff --git a/optional/build.gradle.kts b/optional/build.gradle.kts
index a819cfed16..b813615a6f 100644
--- a/optional/build.gradle.kts
+++ b/optional/build.gradle.kts
@@ -14,8 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-group = "org.apache.sis"
-version = "2.0-SNAPSHOT"
 
 val pathToFX = System.getenv("PATH_TO_FX")
 if (pathToFX == null) {
@@ -26,13 +24,11 @@ if (!File(pathToFX, "javafx.base.jar").isFile()) {
 }
 
 /*
- * "org.apache.sis.buildtools" is a custom Gradle plugin for building a project with Module Source Hierarchy.
+ * This project uses a custom Gradle plugin for building a project with Module Source Hierarchy.
  * See the Gradle build script in the `endorsed` directory for more information.
  */
 plugins {
-    `java-library`
-    `maven-publish`
-    signing
+    id("sis.library-conventions")
     id("org.apache.sis.buildtools")
 }
 
@@ -175,23 +171,6 @@ publishing {
             }
         }
     }
-    /* Following block is currently repeated in all sub-projects. */
-    repositories {
-        maven {
-            name = "Apache"
-            url = uri(if (version.toString().endsWith("SNAPSHOT"))
-                      "https://repository.apache.org/content/repositories/snapshots" else
-                      "https://repository.apache.org/service/local/staging/deploy/maven2")
-            credentials {
-                val asfNexusUsername = providers.gradleProperty("asfNexusUsername")
-                val asfNexusPassword = providers.gradleProperty("asfNexusPassword")
-                if (asfNexusUsername.isPresent() && asfNexusPassword.isPresent()) {
-                    username = asfNexusUsername.get()
-                    password = asfNexusPassword.get()
-                }
-            }
-        }
-    }
 }
 
 signing {