import org.apache.tools.ant.filters.ReplaceTokens plugins { id "com.jfrog.bintray" version "1.8.5" id 'java-library' id "org.nosphere.gradle.github.actions" version "1.1.0" id 'maven-publish' id 'com.palantir.git-version' version "0.12.3" id "io.github.gradle-nexus.publish-plugin" version "1.0.0" id "signing" } // calculate version string from git tag, hash and commit distance if (versionDetails().isCleanTag) { // drop first 'v' from version tag version = gitVersion().substring(1) } else { version = versionDetails().lastTag.substring(1) + '-' + versionDetails().commitDistance + '-' + versionDetails().gitHash + '-SNAPSHOT' } // common settings subprojects { apply plugin: 'jacoco' apply plugin: 'java' apply plugin: 'checkstyle' apply plugin: 'maven' apply plugin: 'maven-publish' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' checkstyle { config = resources.text.fromFile("${rootProject.projectDir}/config/checkstyle/checkstyle.xml") ignoreFailures = true toolVersion = '6.16.1' } version = rootProject.version group = projectGroup repositories { mavenCentral() } dependencies { testImplementation 'commons-io:commons-io:2.6' testImplementation 'org.testng:testng:6.9.10' } test.useTestNG() java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 withSourcesJar() withJavadocJar() } javadoc { options.locale = 'en_US' } artifacts { archives jar archives sourcesJar archives javadocJar } } project(':dictzip-lib') { apply plugin: 'java-library' apply plugin: 'com.jfrog.bintray' version = rootProject.version bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_KEY') configurations = ['archives'] pkg { repo = 'maven' name = 'dictzip-lib' userOrg = 'dictzip' licenses = ['GPL-2.0+CE'] vcsUrl = projectUrl labels = ['java', 'dictzip'] publicDownloadNumbers = true } } install { repositories.mavenInstaller { pom.project { name = project.name packaging = 'jar' description = projectDesc url = projectUrl version = project.version licenses { license { name = licenseName url = licenseUrl distribution = 'repo' } } scm { url = githubUrl connection = "scm:git:${githubUrl}" developerConnection = "scm:git:${githubUrl}" } developers { developer { id = projectOwner name = developerName email = developerEmail } } } } } publishing { publications { project.afterEvaluate { mavenJava(MavenPublication) { from components.java artifactId = "dictzip" groupId = projectGroup version = project.version.toString() pom { name.set(project.name) description.set(projectDesc) url.set(projectUrl) licenses { license { name.set("GNU General Public License Version 2+CE") url.set("https://www.gnu.org/licenses/old-licenses/gpl-2.0") } } 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 = "miurahr" name = "Hiroshi Miura" email = "miurahr@linux.com" } } issueManagement { url.set(projectUrl + "/issues") } } } } } repositories { maven { name = "GitHubPackages" url = "https://maven.pkg.github.com/dictzip/dictzip-java" credentials { username = System.getenv("GITHUB_ACTOR") password = System.getenv("GITHUB_TOKEN") } } maven { name 'AzurePackages' url 'https://pkgs.dev.azure.com/miurahr/github/_packaging/maven/maven/v1' credentials(PasswordCredentials) { username = System.getenv("AZURE_USER") password = System.getenv("AZURE_TOKEN") } authentication { basic(BasicAuthentication) } } } } nexusPublishing { repositories { sonatype { 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') } } } project.afterEvaluate { signing { def signingKey = findProperty("signingKey") def signingPassword = findProperty("signingPassword") if (signingKey) { useInMemoryPgpKeys(signingKey, signingPassword) } else { useGpgCmd() } sign publishing.publications.mavenJava } tasks.withType(Sign) { 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' } task mandoc(type: Copy) { from "doc/dictzip.1.in" into 'build/docs' rename { String fileName -> fileName.replace('dictzip.1.in', 'dictzip.1') } filter(ReplaceTokens, tokens: [copyright: projectYears, version: project.version]) } distTar { compression = Compression.GZIP } distTar.dependsOn mandoc distributions { main { baseName = 'dictzip' contents { from('build/docs/dictzip.1') { into 'docs/man/man1' } from(javadocJar) { into 'docs' } from(sourcesJar) { into 'source' } } } } }