From db011ab6dad804e9523fc7256450373e9a087261 Mon Sep 17 00:00:00 2001 From: Leo Galambos Date: Mon, 4 Aug 2025 02:08:52 +0200 Subject: [PATCH] Build process modification feat: Javadoc footer improvement, deployment to a website chore: build process clean-up Signed-off-by: Leo Galambos --- app/build.gradle | 57 +++++++++++-------- .../buildlogic.java-common-conventions.gradle | 29 +++++++++- gradle.properties | 1 + lib/build.gradle | 7 ++- settings.gradle | 6 ++ 5 files changed, 71 insertions(+), 29 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3d658fa..57661d0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,10 +1,9 @@ plugins { id 'buildlogic.java-application-conventions' - id 'com.palantir.git-version' version '4.0.0' + id 'com.palantir.git-version' } group 'org.egothor' -version gitVersion(prefix:'release@') dependencies { implementation 'org.apache.commons:commons-text' @@ -20,33 +19,41 @@ application { } jar { - manifest { - attributes( - 'Main-Class': application.mainClass, - 'Implementation-Title': rootProject.name, - 'Implementation-Version': "${version}" - ) - } - - // Include compiled classes from main source set - from sourceSets.main.output - - dependsOn configurations.runtimeClasspath - from { - configurations.runtimeClasspath.collect { dep -> - if (dep.isDirectory()) { - dep - } else { - zipTree(dep).matching { - exclude 'META-INF/LICENSE.*' - exclude 'META-INF/*.SF' - exclude 'META-INF/*.DSA' - exclude 'META-INF/*.RSA' + manifest { + attributes( + 'Main-Class': application.mainClass, + 'Implementation-Title': rootProject.name, + 'Implementation-Version': "${version}" + ) + } + + from sourceSets.main.output + + dependsOn configurations.runtimeClasspath + + // Include each JAR dependency + configurations.runtimeClasspath.findAll { it.exists() && it.name.endsWith('.jar') }.each { jarFile -> + def jarName = jarFile.name.replaceAll(/\.jar$/, '') + + from(zipTree(jarFile)) { + // Exclude signature-related files + exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA' + + // Rename license/notice files to avoid conflicts + eachFile { file -> + if (file.path ==~ /META-INF\/(LICENSE|NOTICE)(\..*)?/) { + file.path = "META-INF/licenses-from-${jarName}/${file.name}" } } + + includeEmptyDirs = false } } duplicatesStrategy = DuplicatesStrategy.EXCLUDE - } + +javadoc { + options.links("https://www.egothor.org/javadoc/zeroecho/lib") +} + diff --git a/buildSrc/src/main/groovy/buildlogic.java-common-conventions.gradle b/buildSrc/src/main/groovy/buildlogic.java-common-conventions.gradle index 81f0641..8b5e827 100644 --- a/buildSrc/src/main/groovy/buildlogic.java-common-conventions.gradle +++ b/buildSrc/src/main/groovy/buildlogic.java-common-conventions.gradle @@ -7,8 +7,14 @@ plugins { id 'java' id 'maven-publish' id 'pmd' + id 'com.palantir.git-version' } +import java.time.LocalDate + +def currentYear = LocalDate.now().getYear() +def version = gitVersion(prefix:'release@') + repositories { maven { @@ -26,7 +32,7 @@ dependencies { implementation 'org.apache.commons:commons-text:1.11.0' implementation 'commons-cli:commons-cli:1.9.0' implementation 'org.bouncycastle:bcpkix-jdk18on:1.81' - implementation 'org.egothor:conflux:1.1.0' + implementation 'org.egothor:conflux:[1.0,2.0)' implementation 'org.apache.commons:commons-imaging:1.0.0-alpha6' } @@ -73,10 +79,28 @@ javadoc { options.tags('factory') options.tags('see') - options.bottom = "Copyright © 2025 Egothor" + options.bottom = "Copyright © ${currentYear} Egothor - Version ${version}" source = sourceSets.main.allJava } +task uploadJavadoc(type: Exec) { + dependsOn javadoc + + doFirst { + def javadocDir = tasks.javadoc.destinationDir + def relativeJavadocDir = project.projectDir.toPath().relativize(javadocDir.toPath()).toString() + def moduleName = project.name // Dynamically get the module name + + println "Uploading Javadoc for module: ${moduleName}" + println "Uploading from relative path: $relativeJavadocDir" + + // Upload to a folder named after the module + commandLine "rsync", "-avz", "--delete", + "-e", "ssh -i ${javadocKeyPath} -o IdentitiesOnly=yes", + relativeJavadocDir + '/', "${javadocUser}@${javadocHost}:${javadocPath}/${project.name}" + } +} + tasks.named('test') { // Use JUnit Platform for unit tests. useJUnitPlatform() @@ -87,6 +111,7 @@ if (project.hasProperty('giteaToken') && project.giteaToken) { publications { mavenJava(MavenPublication) { from components.java + artifactId = "${rootProject.name}-${project.name}" } } repositories { diff --git a/gradle.properties b/gradle.properties index f445307..0f591a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g +javadocPath=/var/www/html/javadoc/zeroecho/ diff --git a/lib/build.gradle b/lib/build.gradle index 6a038f2..077853e 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -1,13 +1,16 @@ plugins { id 'buildlogic.java-library-conventions' - id 'com.palantir.git-version' version '4.0.0' + id 'com.palantir.git-version' } group 'org.egothor' -version gitVersion(prefix:'release@') dependencies { implementation 'org.bouncycastle:bcpkix-jdk18on' implementation 'org.egothor:conflux' implementation 'org.apache.commons:commons-imaging' } + +javadoc { + options.links("https://www.egothor.org/javadoc/conflux") +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 13dc704..89e97b1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,9 @@ +pluginManagement { + plugins { + id 'com.palantir.git-version' version '4.0.0' // Define the plugin version globally + } +} + plugins { // Apply the foojay-resolver plugin to allow automatic download of JDKs id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'