OSDN Git Service

chore: split build.gradle in subprojects
authorHiroshi Miura <miurahr@linux.com>
Sun, 8 Oct 2023 11:01:36 +0000 (20:01 +0900)
committerHiroshi Miura <miurahr@linux.com>
Sun, 8 Oct 2023 11:01:36 +0000 (20:01 +0900)
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
build.gradle
dictzip-cli/build.gradle [new file with mode: 0644]
dictzip-lib/build.gradle [new file with mode: 0644]
northside-io/build.gradle [new file with mode: 0644]

index 5d881bb..9490c66 100644 (file)
@@ -1,13 +1,10 @@
-import org.apache.tools.ant.filters.ReplaceTokens
-
 plugins {
-    id 'java-library'
-    id 'maven-publish'
-    id 'java-library-distribution'
-    id "io.github.gradle-nexus.publish-plugin" version "1.2.0"
-    id 'com.palantir.git-version' version "0.13.0"
+    alias(libs.plugins.nexus.publish)
+    alias(libs.plugins.git.version)
 }
 
+group = projectGroup
+
 // calculate version string from git tag, hash and commit distance
 // It treat as release tag when current HEAD has a tag,
 // and repository is clean, no modification,and no untracked files,
@@ -17,183 +14,3 @@ if (versionDetails().isCleanTag) {
 } else {
     version = versionDetails().lastTag.substring(1) + '-' + versionDetails().commitDistance + '-' + versionDetails().gitHash + '-SNAPSHOT'
 }
-
-def props = project.file("dictzip-cli/src/main/resources/org/dict/zip/Version.properties")
-tasks.register('writeVersionFile') {
-    def folder = props.getParentFile()
-    if (!folder.exists()) {
-        folder.mkdirs()
-    }
-    props.delete()
-    props.text = "version=" + project.version
-}
-
-jar.dependsOn("writeVersionFile")
-
-// common settings
-subprojects {
-    apply plugin: 'jacoco'
-    apply plugin: 'java'
-    apply plugin: 'checkstyle'
-    apply plugin: 'maven-publish'
-
-    checkstyle {
-        ignoreFailures = true
-        toolVersion = '6.16.1'
-    }
-    version = rootProject.version
-    group = projectGroup
-
-    repositories {
-        mavenCentral()
-    }
-
-    dependencies {
-        implementation "org.jetbrains:annotations:23.0.0"
-        testImplementation 'commons-io:commons-io:2.11.0'
-        testImplementation "org.junit.jupiter:junit-jupiter:5.9.2"
-    }
-    test {
-        useJUnitPlatform()
-    }
-
-    java {
-        toolchain {
-            languageVersion = JavaLanguageVersion.of(8)
-            vendor = JvmVendorSpec.ADOPTIUM
-        }
-        withSourcesJar()
-        withJavadocJar()
-    }
-
-    javadoc {
-        options.locale = 'en_US'
-    }
-
-    artifacts {
-        archives jar
-        archives sourcesJar
-        archives javadocJar
-    }
-}
-
-project(':northside-io') {
-    apply plugin: 'java-library'
-    version = rootProject.version
-    dependencies {
-        implementation 'commons-io:commons-io:2.11.0'
-    }
-}
-
-project(':dictzip-lib') {
-    apply plugin: 'java-library'
-    apply plugin: "signing"
-    version = rootProject.version
-
-    dependencies {
-        testImplementation project(':northside-io')
-    }
-
-    publishing {
-        publications {
-            mavenJava(MavenPublication) {
-                from components.java
-                artifactId = 'dictzip'
-                pom {
-                    name.set("dictzip")
-                    description.set(projectDesc)
-                    url.set(projectUrl)
-                    licenses {
-                        license {
-                            name.set("GNU General Public License v2.0 w/Classpath exception")
-                            url.set("https://www.gnu.org/software/classpath/license.html")
-                        }
-                    }
-                    scm {
-                        connection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
-                        developerConnection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
-                        url.set(projectUrl)
-                    }
-                    developers {
-                        developer {
-                            id.set("miurahr")
-                            name.set("Hiroshi Miura")
-                            email.set("miurahr@linux.com")
-                        }
-                    }
-                    issueManagement {
-                        url.set(projectUrl + "/issues")
-                    }
-                }
-            }
-        }
-    }
-    nexusPublishing {
-        repositories {
-            sonatype {
-                stagingProfileId.set("a1cf138b142cd")
-                nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
-                snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
-                username = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : System.getenv('SONATYPE_USER')
-                password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : System.getenv('SONATYPE_PASS')
-            }
-        }
-    }
-
-    signing {
-        if (project.hasProperty("signingKey")) {
-            def signingKey = findProperty("signingKey").toString()
-            def signingPassword = findProperty("signingPassword").toString()
-            useInMemoryPgpKeys(signingKey, signingPassword)
-        } else {
-            useGpgCmd()
-        }
-        sign publishing.publications.mavenJava
-    }
-    tasks.withType(Sign).configureEach {
-        def hasKey = project.hasProperty("signingKey") || project.hasProperty("signing.gnupg.keyName")
-        onlyIf { hasKey && versionDetails().isCleanTag }
-    }
-}
-
-project(':dictzip-cli') {
-    apply plugin: 'application'
-    mainClassName = 'org.dict.zip.cli.Main'
-    applicationName = 'dictzip'
-    version = rootProject.version
-    dependencies {
-        implementation project(':dictzip-lib')
-        implementation 'gnu.getopt:java-getopt:1.0.13'
-        testImplementation project(':northside-io')
-    }
-    tasks.register('mandoc', Copy) {
-        from "doc/dictzip.1.in"
-        into "$buildDir/docs/man"
-        rename { String fileName ->
-            fileName.replace('dictzip.1.in', 'dictzip.1')
-        }
-        filter(ReplaceTokens, tokens: [copyright: projectYears, version: project.version])
-        duplicatesStrategy = DuplicatesStrategy.INCLUDE
-    }
-
-    distTar {
-        compression = Compression.GZIP
-    }
-    distTar.dependsOn mandoc
-
-    distributions {
-        main {
-            contents {
-                from(tasks.mandoc.outputs) {
-                    into 'docs/man/man1'
-                }
-                from(javadocJar) {
-                    into 'docs'
-                }
-                from(sourcesJar) {
-                    into 'source'
-                }
-            }
-        }
-    }
-}
diff --git a/dictzip-cli/build.gradle b/dictzip-cli/build.gradle
new file mode 100644 (file)
index 0000000..df2c619
--- /dev/null
@@ -0,0 +1,79 @@
+import org.apache.tools.ant.filters.ReplaceTokens
+
+plugins {
+    id 'application'
+    id 'jacoco'
+    id 'checkstyle'
+}
+
+application {
+    mainClass = 'org.dict.zip.cli.Main'
+    applicationName = 'dictzip'
+}
+
+version = rootProject.version
+
+def props = project.file("src/main/resources/org/dict/zip/Version.properties")
+tasks.register('writeVersionFile') {
+    def folder = props.getParentFile()
+    if (!folder.exists()) {
+        folder.mkdirs()
+    }
+    props.delete()
+    props.text = "version=" + project.version
+}
+jar.dependsOn("writeVersionFile")
+
+repositories {
+    mavenCentral()
+}
+
+dependencies {
+    implementation project(':dictzip-lib')
+    implementation(libs.jetbrains.annotations)
+    testImplementation(libs.commons.io)
+    testImplementation(libs.junit.jupiter)
+    implementation 'gnu.getopt:java-getopt:1.0.13'
+    testImplementation project(':northside-io')
+}
+
+test {
+    useJUnitPlatform()
+}
+
+java {
+    toolchain {
+        languageVersion = JavaLanguageVersion.of(11)
+        vendor = JvmVendorSpec.ADOPTIUM
+    }
+}
+
+tasks.register('mandoc', Copy) {
+    from "doc/dictzip.1.in"
+    into layout.buildDirectory.file("docs/man")
+    rename { String fileName ->
+        fileName.replace('dictzip.1.in', 'dictzip.1')
+    }
+    filter ReplaceTokens, tokens: [copyright: projectYears, version: project.version]
+    duplicatesStrategy = DuplicatesStrategy.INCLUDE
+}
+
+distTar {
+    compression = Compression.GZIP
+}
+distTar.dependsOn mandoc
+
+distributions {
+    main {
+        contents {
+            from(tasks.mandoc.outputs) {
+                into 'docs/man/man1'
+            }
+        }
+    }
+}
+
+checkstyle {
+    ignoreFailures = true
+    toolVersion = libs.versions.checkstyle.get()
+}
diff --git a/dictzip-lib/build.gradle b/dictzip-lib/build.gradle
new file mode 100644 (file)
index 0000000..c58b884
--- /dev/null
@@ -0,0 +1,105 @@
+plugins {
+    id 'java-library'
+    id 'jacoco'
+    id 'checkstyle'
+    id 'signing'
+    id 'maven-publish'
+}
+
+version = rootProject.version
+
+repositories {
+    mavenCentral()
+}
+
+dependencies {
+    implementation(libs.jetbrains.annotations)
+    testImplementation(libs.junit.jupiter)
+    testImplementation(libs.commons.io)
+    testImplementation project(':northside-io')
+}
+
+test {
+    useJUnitPlatform()
+}
+
+java {
+    toolchain {
+        languageVersion = JavaLanguageVersion.of(11)
+        vendor = JvmVendorSpec.ADOPTIUM
+    }
+    withSourcesJar()
+    withJavadocJar()
+}
+
+javadoc {
+    options.locale = 'en_US'
+}
+
+artifacts {
+    archives jar
+    archives sourcesJar
+    archives javadocJar
+}
+
+publishing {
+    publications {
+        mavenJava(MavenPublication) {
+            from components.java
+            artifactId = 'dictzip' as Publication
+            pom {
+                name.set("dictzip")
+                description.set(projectDesc)
+                url.set(projectUrl)
+                licenses {
+                    license {
+                        name.set("GNU General Public License v2.0 w/Classpath exception")
+                        url.set("https://www.gnu.org/software/classpath/license.html")
+                    }
+                }
+                scm {
+                    connection.set("scm:git:git://codeberg.org/miurahr/dictzip-java.git")
+                    developerConnection.set("scm:git:git://codeberg.org/miurahr/dictzip-java.git")
+                    url.set(projectUrl)
+                }
+                developers {
+                    developer {
+                        id.set("miurahr")
+                        name.set("Hiroshi Miura")
+                        email.set("miurahr@linux.com")
+                    }
+                }
+                issueManagement {
+                    url.set(projectUrl + "/issues")
+                }
+            }
+        }
+    }
+}
+nexusPublishing.repositories {
+    sonatype {
+        username = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : System.getenv('SONATYPE_USER')
+        password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : System.getenv('SONATYPE_PASS')
+    }
+}
+
+signing {
+    if (project.hasProperty("signingKey")) {
+        def signingKey = findProperty("signingKey").toString()
+        def signingPassword = findProperty("signingPassword").toString()
+        useInMemoryPgpKeys(signingKey, signingPassword)
+    } else {
+        useGpgCmd()
+    }
+    sign publishing.publications.mavenJava
+}
+
+tasks.withType(Sign).configureEach {
+    def hasKey = project.hasProperty("signingKey") || project.hasProperty("signing.gnupg.keyName")
+    onlyIf { hasKey && versionDetails().isCleanTag }
+}
+
+checkstyle {
+    ignoreFailures = true
+    toolVersion = libs.versions.checkstyle.get()
+}
diff --git a/northside-io/build.gradle b/northside-io/build.gradle
new file mode 100644 (file)
index 0000000..ce14009
--- /dev/null
@@ -0,0 +1,20 @@
+plugins {
+    id 'java-library'
+}
+
+version = rootProject.version
+
+repositories {
+    mavenCentral()
+}
+
+dependencies {
+    implementation(libs.commons.io)
+    implementation(libs.jetbrains.annotations)
+    testImplementation(libs.junit.jupiter)
+}
+
+test {
+    useJUnitPlatform()
+}
+