From c550a8e712cf2d573880f53becd3dd48fa6efec9 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 25 Dec 2023 16:00:36 -0800 Subject: [PATCH 1/5] Simplify dependencies. --- gradle.properties | 1 - selfie-runner-junit5/build.gradle | 11 ++--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6cda67d0..4aac180b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,6 @@ git_url=github.com/diffplug/selfie maven_group=com.diffplug.selfie javadoc_links= -ver_JUNIT_API=5.0.0 ver_JUNIT_USE=5.10.1 ver_JUNIT_PIONEER=2.1.0 ver_OKIO=3.6.0 diff --git a/selfie-runner-junit5/build.gradle b/selfie-runner-junit5/build.gradle index 99a853b9..b07d195c 100644 --- a/selfie-runner-junit5/build.gradle +++ b/selfie-runner-junit5/build.gradle @@ -14,15 +14,8 @@ apply from: rootProject.file('gradle/spotless.gradle') apply plugin: 'java-library' dependencies { api project(':selfie-lib') - // see if we can drop this down to 1.0.0 - implementation 'org.junit.platform:junit-platform-launcher:1.10.1' - compileOnly "org.junit.jupiter:junit-jupiter-api:$ver_JUNIT_API" - // jsoup - compileOnly 'org.jsoup:jsoup:1.17.1' - testImplementation 'org.jsoup:jsoup:1.17.1' - // flexmark - compileOnly 'com.vladsch.flexmark:flexmark-html2md-converter:0.64.8' - testImplementation 'com.vladsch.flexmark:flexmark-html2md-converter:0.64.8' + implementation 'org.junit.platform:junit-platform-launcher:1.0.0' + compileOnly "org.junit.jupiter:junit-jupiter-api:5.0.0" testImplementation "com.squareup.okio:okio:$ver_OKIO" testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:$ver_KOTLIN_TEST" From 3c541f8dc0d3b20bf1e31ed64280ecda537e99f6 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 25 Dec 2023 16:48:36 -0800 Subject: [PATCH 2/5] =?UTF-8?q?Replace=20`=E5=B9=B2.file('base/maven.gradl?= =?UTF-8?q?e')`=20with=20an=20in-repo=20script=20as=20we=20workout=20KMP.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle/maven.gradle | 88 +++++++++++++++++++++++++++++++ selfie-lib/build.gradle | 2 +- selfie-runner-junit5/build.gradle | 2 +- 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 gradle/maven.gradle diff --git a/gradle/maven.gradle b/gradle/maven.gradle new file mode 100644 index 00000000..04fe9d72 --- /dev/null +++ b/gradle/maven.gradle @@ -0,0 +1,88 @@ +// 干.mustRunAfter('base/gradle-plugin') +// 干.mustRunAfter('base/changelog') + +apply plugin: 'maven-publish' + +def git_url = 干.proj('git_url', 'the git url with no protocol, e.g.: github.com/diffplug/blowdryer') +assert !git_url.startsWith('https://') : 'git_url should not start with https://' +assert !git_url.startsWith('http://') : 'git_url should not start with http://' + +group = 干.proj('maven_group', 'the maven group, recommend com.diffplug') +def maven_artifact = project.name +def maven_name = 干.proj('maven_name', 'human-friendly name') +def maven_desc = 干.proj('maven_desc', 'human-friendly description') + +def javadocLinks = 干.proj('javadoc_links', "space-delimited links, if you add '/package-list' to the urls you should get a package list").split() +def license = 干.proj('license', 'supported: [apache, confidential, lgpl-2.1]') + +def license_name = 干.prop('base/maven', "${license}_name") +def license_url = 干.prop('base/maven', "${license}_url") +def license_comments = 干.prop('base/maven', "${license}_comments") + +boolean isKMP = project.pluginManager.hasPlugin('org.jetbrains.kotlin.multiplatform') +if (!isKMP) { + java { + withJavadocJar() + withSourcesJar() + } + + tasks.named('sourcesJar') { + dependsOn 'jar' + } + + javadoc { + def makeLink = { url, text -> "${text}" } + def javadocInfo = '

' + makeLink("https://${git_url}", "${maven_artifact}:${version}") + + ' by ' + makeLink('https://www.diffplug.com', 'DiffPlug') + '

'; + // Where it's possible to name parameters and methods clearly enough + // that javadoc is not necessary, why make the code bigger? + // Thus, no javadoc warnings. + options.addStringOption('Xdoclint:none', '-quiet') + // UTF-8!!! Thanks to: https://github.com/freefair/gradle-plugins/blob/6d6f5ff6036e7da1c329075a02c6452c0bb669be/maven-plugin/src/main/java/io/freefair/gradle/plugins/maven/javadoc/JavadocUtf8Plugin.java + options.charSet('UTF-8'); + options.docEncoding('UTF-8'); + options.setEncoding('UTF-8'); + // setup the header + options.header javadocInfo + options.footer javadocInfo + // setup links + options.links(javadocLinks) + } + apply from: 干.file('helper/javadoc-view.gradle') +} + + +boolean isPlugin = plugins.hasPlugin('java-gradle-plugin') +publishing.publications.register(isPlugin ? 'pluginMaven' : 'mavenJava', MavenPublication, { + artifactId = maven_artifact + if (!isPlugin && !isKMP) { + from components.java + } + pom { + name = maven_name + description = maven_desc + url = "https://$git_url" + licenses { + // has to be it.license because of parameter license above + it.license { + // https://maven.apache.org/pom.html#Licenses + name = license_name + url = license_url + distribution = 'repo' + comments = license_comments + } + } + developers { + developer { + id = 'nedtwigg' + name = 'Ned Twigg' + email = 'ned.twigg@diffplug.com' + } + } + scm { + connection = "scm:git:git://${git_url}.git" + developerConnection = "scm:git:ssh://${git_url}.git" + url = "https://$git_url" + } + } +}) diff --git a/selfie-lib/build.gradle b/selfie-lib/build.gradle index ea486491..160364d7 100644 --- a/selfie-lib/build.gradle +++ b/selfie-lib/build.gradle @@ -40,5 +40,5 @@ tasks.create('test') { } // it all needs to get published and formatted -apply from: 干.file('base/maven.gradle') +apply from: rootProject.file('gradle/maven.gradle') apply from: 干.file('base/sonatype.gradle') \ No newline at end of file diff --git a/selfie-runner-junit5/build.gradle b/selfie-runner-junit5/build.gradle index b07d195c..4f0d5ee6 100644 --- a/selfie-runner-junit5/build.gradle +++ b/selfie-runner-junit5/build.gradle @@ -31,5 +31,5 @@ test { } // it all needs to get published and formatted -apply from: 干.file('base/maven.gradle') +apply from: rootProject.file('gradle/maven.gradle') apply from: 干.file('base/sonatype.gradle') From 700dd25fbf6abe8a1017d3c504f05b343c7205df Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 25 Dec 2023 17:00:40 -0800 Subject: [PATCH 3/5] Fix mavenCentral POM. --- gradle/maven.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gradle/maven.gradle b/gradle/maven.gradle index 04fe9d72..1fff702f 100644 --- a/gradle/maven.gradle +++ b/gradle/maven.gradle @@ -51,9 +51,8 @@ if (!isKMP) { apply from: 干.file('helper/javadoc-view.gradle') } - boolean isPlugin = plugins.hasPlugin('java-gradle-plugin') -publishing.publications.register(isPlugin ? 'pluginMaven' : 'mavenJava', MavenPublication, { +publishing.publications.withType(MavenPublication) { artifactId = maven_artifact if (!isPlugin && !isKMP) { from components.java @@ -85,4 +84,4 @@ publishing.publications.register(isPlugin ? 'pluginMaven' : 'mavenJava', MavenPu url = "https://$git_url" } } -}) +} From b716aba4a18d4a68ed2b4456e78be1ab3d87a279 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 25 Dec 2023 18:01:00 -0800 Subject: [PATCH 4/5] Fix KMP issues with the previous workaround. --- gradle/maven.gradle | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gradle/maven.gradle b/gradle/maven.gradle index 1fff702f..e08c729b 100644 --- a/gradle/maven.gradle +++ b/gradle/maven.gradle @@ -53,7 +53,14 @@ if (!isKMP) { boolean isPlugin = plugins.hasPlugin('java-gradle-plugin') publishing.publications.withType(MavenPublication) { - artifactId = maven_artifact + // KMP-aware artifactId + if (artifactId.endsWith('-jvm')) { + artifactId = maven_artifact + '-jvm' + } else if (artifactId.endsWith("-js")) { + artifactId = maven_artifact + '-js' + } else { + artifactId = maven_artifact + } if (!isPlugin && !isKMP) { from components.java } From 130ae600a4b551b75c82092ddbd750d35635ebc4 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 25 Dec 2023 23:23:13 -0800 Subject: [PATCH 5/5] Add javadoc for KMP --- gradle/maven.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gradle/maven.gradle b/gradle/maven.gradle index e08c729b..817b854b 100644 --- a/gradle/maven.gradle +++ b/gradle/maven.gradle @@ -56,6 +56,13 @@ publishing.publications.withType(MavenPublication) { // KMP-aware artifactId if (artifactId.endsWith('-jvm')) { artifactId = maven_artifact + '-jvm' + // create javadoc manually to keep MavenCentral happy + def javadocJar = tasks.register('dokkaJavadoc', Jar.class) { + dependsOn('dokkatooGenerate') + archiveClassifier.set("javadoc") + from('build/dokka-module/html') + } + artifact javadocJar } else if (artifactId.endsWith("-js")) { artifactId = maven_artifact + '-js' } else {