From 05dcf4034a728f79ef55dff6370692a5dbe7d92a Mon Sep 17 00:00:00 2001 From: Alejandro Revilla Date: Tue, 15 Oct 2024 19:22:53 -0300 Subject: [PATCH] simplified build.gradle, gracefully handle bom --- VERSION | 1 + build.gradle | 220 +++++++++++++++++++++++++++++---------------- publishing.gradle | 36 -------- subprojects.gradle | 74 --------------- 4 files changed, 142 insertions(+), 189 deletions(-) create mode 100644 VERSION delete mode 100644 publishing.gradle delete mode 100644 subprojects.gradle diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..95130604c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +PROJECT_VERSION="3.0.0-SNAPSHOT" diff --git a/build.gradle b/build.gradle index 0bc2b2a38..c68cc84e3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,113 +1,175 @@ plugins { - id 'org.jpos.jposapp' version '0.0.10' + id 'org.jpos.jposapp' version '0.0.11' id 'idea' id 'org.gradlex.extra-java-module-info' version '1.9' } +import org.gradle.internal.os.OperatingSystem -// if (file('libraries.gradle').exists()) -// apply from: 'libraries.gradle' +evaluate(new File("${project.projectDir}/VERSION")) allprojects { - group = 'org.jpos.ee' - version = '3.0.0-SNAPSHOT' apply plugin: 'idea' - gradle.projectsEvaluated { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" - } - } + apply plugin: 'eclipse' } subprojects { - apply from: "${rootProject.projectDir}/publishing.gradle" + apply plugin: 'maven-publish' + apply plugin: 'signing' + group = 'org.jpos.ee' + version = binding.variables.get("PROJECT_VERSION") ?: "0.0.1" if (name != 'bom') { apply plugin: 'java-library' + apply plugin: 'project-report' apply plugin: 'org.jpos.jposapp' - apply from: "${rootProject.projectDir}/subprojects.gradle" + + [ compileJava, compileTestJava, javadoc ]*.options*.encoding = 'UTF-8' + def isSnapshot = version.contains("SNAPSHOT") + def mavenCentralRepo = isSnapshot ? + 'https://oss.sonatype.org/content/repositories/snapshots/' : + 'https://oss.sonatype.org/service/local/staging/deploy/maven2'; + configurations.implementation.transitive = true + javadoc.failOnError = false + + java { + withJavadocJar() + withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_23 + targetCompatibility = JavaVersion.VERSION_23 + } + + tasks.withType(JavaCompile) { + options.release = JavaVersion.VERSION_23.ordinal() + } + repositories { + mavenCentral() + maven { url = uri('https://jpos.org/maven') } + mavenLocal() + } + if (project.hasProperty("lint")) { + // gradle -Plint ... + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:preview" << "-Xlint:unchecked" << "-Xlint:deprecation" + } + } + publishing { + publications { + mavenJava(MavenPublication) { + pom { + name = 'jPOS Project' + description = """ + jPOS is an ISO-8583 based financial transaction + library/framework that can be customized and + extended in order to implement financial interchanges. + """ + url = "https://jpos.org" + organization { + name = 'jPOS.org' + url = 'https://jpos.org' + } + issueManagement { + system = 'Github Issues' + url = 'https://github.com/jpos/jPOS-EE/issues' + } + scm { + url = "http://github.com/jpos/jPOS-EE" + connection = "scm:git:https://github.com/jpos/jPOS-EE.git" + developerConnection = "scm:git:git@github.com:jpos/jPOS-EE.git" + } + licenses { + license { + name = 'GNU AFFERO GENERAL PUBLIC LICENSE' + url = 'http://www.gnu.org/licenses/agpl-v3.html' + comments = 'See http://jpos.org/license for more details.' + distribution = 'repo' + } + } + developers { + developer { + id = 'jpos-team' + name = 'jPOS Development Team' + email = 'info@jpos.org' + } + } + } + groupId = 'org.jpos.ee' + artifactId="jposee-${project.name}" + from components.java + } + } + repositories { + maven { + def releasesRepoUrl = mavenCentralRepo + def snapshotsRepoUrl = 'file:///opt/local/maven' + url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl + if (!isSnapshot) { + credentials { + if (project.hasProperty("mavenCentralUsername")) + username = mavenCentralUsername + if (project.hasProperty("mavenCentralPassword")) + password = mavenCentralPassword + } + } + } + } + } + + signing { + required { !isSnapshot } + sign publishing.publications.mavenJava + } + + javadoc { + configure(options) { + windowTitle = "jPOS-EE ${project.version}" + header = "jPOS-EE ${project.version}" + linkSource = true + links( + 'https://docs.oracle.com/en/java/javase/23/docs/api' + ) + tags( + 'apiNote:a:API Note:', + 'implSpec:a:Implementation Requirements:', + 'implNote:a:Implementation Note:' + ) + } + } + test { - useJUnitPlatform() + useJUnitPlatform() testLogging { events "passed", "skipped", "failed" } systemProperty 'user.language', 'en' -// if (!(System.getenv("GITHUB_ACTIONS") != null && System.getenv("GITHUB_ACTIONS") == "true" && -// (OperatingSystem.current().isMacOsX() || OperatingSystem.current().isWindows()))) { -// maxParallelForks = Runtime.runtime.availableProcessors() -// } - } - dependencies{ - testImplementation testlibs.junit - testRuntimeOnly testlibs.junitRuntime + if (!(System.getenv("GITHUB_ACTIONS") != null && System.getenv("GITHUB_ACTIONS") == "true" && + (OperatingSystem.current().isMacOsX() || OperatingSystem.current().isWindows()))) { + maxParallelForks = Runtime.runtime.availableProcessors() + } } } - repositories { - mavenCentral() - maven { url = uri('https://jpos.org/maven') } - mavenLocal() - } - base { - archivesName="jposee-${project.name}" - } - java { - sourceCompatibility = JavaVersion.VERSION_23 - targetCompatibility = JavaVersion.VERSION_23 - withSourcesJar() - } } +// Configure IDEA to use Git idea { project { ipr { - withXml { - provider -> provider.node.component.find { - it.@name == 'VcsDirectoryMappings' - }.mapping.@vcs = 'Git' + withXml { + provider -> provider.node.component.find { + it.@name == 'VcsDirectoryMappings' + }.mapping.@vcs = 'Git' } } languageLevel = '23' } } - - -// apply from: 'libraries.gradle' - - -// buildscript { -// repositories { -// mavenCentral() -// } -// dependencies { -// classpath 'org.owasp:dependency-check-gradle:6.1.5' -// } -//} - -//allprojects { -// apply plugin: 'idea' -// apply plugin: 'eclipse' -// apply plugin: 'org.owasp.dependencycheck' - -// group = 'org.jpos.ee' -// version = '3.0.0-SNAPSHOT' -// gradle.projectsEvaluated { -// tasks.withType(JavaCompile) { -// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" -// } -// } -//} - -// subprojects { -// apply from: "${rootProject.projectDir}/publishing.gradle" -// if (name != 'bom') { -// apply from: "${rootProject.projectDir}/subprojects.gradle" -// } -// } - -// Configure IDEA to use Git -// idea.project.ipr { -// withXml { provider -> -// provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git' -// } -// } +task aggregatedJavadoc (type: Javadoc, description: "Aggregated Javadocs") { + source subprojects.collect {project -> + project.sourceSets.main.allJava + } + destinationDir = new File(buildDir, 'docs/javadoc') + classpath = files(subprojects.collect {project -> + project.sourceSets.main.compileClasspath}) + failOnError = false +} diff --git a/publishing.gradle b/publishing.gradle deleted file mode 100644 index 1ee03950c..000000000 --- a/publishing.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' - -def isSnapshot = version.contains("SNAPSHOT") -def mavenCentralRepo = isSnapshot ? - 'https://oss.sonatype.org/content/repositories/snapshots/' : - 'https://oss.sonatype.org/service/local/staging/deploy/maven2'; - -base { - archivesName="jposee-${project.name}" -} - -publishing { - repositories { - maven { - def releasesRepoUrl = mavenCentralRepo - def snapshotsRepoUrl = 'file:///opt/local/maven' - url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl - if (!isSnapshot) { - credentials { - if (project.hasProperty("mavenCentralUsername")) - username = mavenCentralUsername - if (project.hasProperty("mavenCentralPassword")) - password = mavenCentralPassword - } - } - } - } -} - -repositories { - mavenCentral() - maven { url 'https://jpos.org/maven' } - mavenLocal() -} - diff --git a/subprojects.gradle b/subprojects.gradle deleted file mode 100644 index 129acffe6..000000000 --- a/subprojects.gradle +++ /dev/null @@ -1,74 +0,0 @@ -apply plugin: 'signing' - -[ compileJava, compileTestJava, javadoc ]*.options*.encoding = 'UTF-8' - -java { - withSourcesJar() -} - -test { - useJUnitPlatform() - maxParallelForks = Runtime.runtime.availableProcessors() -} - -dependencies { - testImplementation libs.junit - //Java 10 support - testImplementation('com.sun.xml.bind:jaxb-impl:2.1.2') - testImplementation('com.sun.activation:javax.activation:1.2.0') - testImplementation('javax.xml.bind:jaxb-api:2.3.0') -} - -publishing { - publications { - mavenJava(MavenPublication) { - pom { - name = 'jPOS Project' - description = "jPOS Extended Edition" - url = "http://jpos.org" - organization { - name = 'jPOS.org' - url = 'http://jpos.org' - } - issueManagement { - system = 'Github Issues' - url = 'https://github.com/jpos/jPOS-EE/issues' - } - scm { - url = "http://github.com/jpos/jPOS-EE" - connection = "scm:git:https://github.com/jpos/jPOS-EE.git" - developerConnection = "scm:git:git@github.com:jpos/jPOS-EE.git" - } - licenses { - license { - name = 'GNU AFFERO GENERAL PUBLIC LICENSE' - url = 'http://www.gnu.org/licenses/agpl-v3.html' - comments = 'See http://jpos.org/license for more details.' - distribution = 'repo' - } - } - developers { - developer { - id = 'jpos-team' - name = 'jPOS Development Team' - email = 'info@jpos.org' - } - } - } - - groupId = 'org.jpos.ee' - artifactId = 'jposee' - from components.java - artifactId="jposee-${project.name}" - } - } -} // publishing - -signing { - def isSnapshot = version.contains("SNAPSHOT") - required { !isSnapshot } - sign publishing.publications.mavenJava -} - -task allDeps(type: DependencyReportTask) {} -