|
1 | | -import love.forte.gradle.common.core.Gpg |
2 | | -import love.forte.gradle.common.publication.configure.configPublishMaven |
3 | | -import love.forte.gradle.common.publication.configure.publishingExtension |
4 | | -import love.forte.gradle.common.publication.configure.setupPom |
5 | | -import love.forte.gradle.common.publication.configure.signingExtension |
6 | | -import utils.isMainPublishable |
7 | | - |
8 | | -plugins { |
9 | | - id("signing") |
10 | | - id("maven-publish") |
11 | | -} |
12 | | - |
13 | | -//setup(IProject) |
14 | | - |
15 | | -//val (sonatypeUsername, sonatypePassword) = sonatypeUserInfoOrNull |
16 | | - |
17 | | -//val sonatypeContains = sonatypeUserInfoOrNull != null |
18 | | -val gpgValue = Gpg.ofSystemPropOrNull() |
19 | | - |
20 | | -// see https://github.com/gradle/gradle/issues/26091#issuecomment-1681343496 |
21 | | - |
22 | | -val p = project |
23 | | - |
24 | | -if (isMainPublishable()) { |
25 | | - val isSnapshot = project.version.toString().contains("SNAPSHOT") |
26 | | - publishingExtension { |
27 | | - repositories { |
28 | | - mavenLocal() |
29 | | - if (isSnapshot) { |
30 | | - configPublishMaven(SnapshotRepository) |
31 | | - } else { |
32 | | - configPublishMaven(ReleaseRepository) |
33 | | - } |
34 | | - } |
35 | | - val jarSources = tasks.register("${p.name}SourceJar", Jar::class) { |
36 | | - archiveClassifier.set("sources") |
37 | | - from(sourceSets["main"].allSource) |
38 | | - } |
39 | | - |
40 | | - val jarJavadoc = tasks.register("${p.name}JavadocJar", Jar::class) { |
41 | | - archiveClassifier.set("javadoc") |
42 | | - } |
43 | | - |
44 | | - publications { |
45 | | - create<MavenPublication>("publicationDist") { |
46 | | - from(components.getByName("java")) |
47 | | - artifact(jarSources) |
48 | | - artifact(jarJavadoc) |
49 | | - version = p.version.toString() |
50 | | - setupPom(p.name, IProject) |
51 | | - } |
52 | | - } |
53 | | - |
54 | | - signingExtension { |
55 | | - val gpg = gpgValue ?: return@signingExtension |
56 | | - |
57 | | - val (keyId, secretKey, password) = gpg |
58 | | - useInMemoryPgpKeys(keyId, secretKey, password) |
59 | | - sign(publishingExtension.publications) |
60 | | - } |
61 | | - } |
62 | | -// jvmConfigPublishing { |
63 | | -// project = IProject |
64 | | -// isSnapshot = project.version.toString().contains("SNAPSHOT", true) |
65 | | -// |
66 | | -// val jarSources = tasks.register("${p.name}SourceJar", Jar::class) { |
67 | | -// archiveClassifier.set("sources") |
68 | | -// from(sourceSets["main"].allSource) |
69 | | -// } |
70 | | -// |
71 | | -// val jarJavadoc = tasks.register("${p.name}JavadocJar", Jar::class) { |
72 | | -//// dependsOn(tasks.dokkaHtml) |
73 | | -//// from(tasks.dokkaHtml.flatMap { it.outputDirectory }) |
74 | | -// archiveClassifier.set("javadoc") |
75 | | -// } |
76 | | -// |
77 | | -// tasks.withType<GenerateModuleMetadata> { |
78 | | -// dependsOn(jarSources) |
79 | | -// dependsOn(jarJavadoc) |
80 | | -// } |
81 | | -// |
82 | | -// artifact(jarSources) |
83 | | -// artifact(jarJavadoc) |
84 | | -// |
85 | | -// releasesRepository = ReleaseRepository |
86 | | -// snapshotRepository = SnapshotRepository |
87 | | -// |
88 | | -// gpg = gpgValue |
89 | | -// } |
90 | | - |
91 | | -} |
92 | | - |
93 | | - |
94 | | -signing { |
95 | | - isRequired = gpgValue != null |
96 | | - if (gpgValue != null) { |
97 | | - val (keyId, secretKey, password) = gpgValue |
98 | | - useInMemoryPgpKeys(keyId, secretKey, password) |
99 | | - sign(publishingExtension.publications) |
100 | | - } |
101 | | -} |
102 | | - |
103 | | -// TODO see https://github.com/gradle-nexus/publish-plugin/issues/208#issuecomment-1465029831 |
104 | | -val signingTasks: TaskCollection<Sign> = tasks.withType<Sign>() |
105 | | -tasks.withType<PublishToMavenRepository>().configureEach { |
106 | | - mustRunAfter(signingTasks) |
107 | | -} |
108 | | -// see https://github.com/gradle/gradle/issues/26091#issuecomment-1722947958 |
109 | | -//region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies |
110 | | -// https://github.com/gradle/gradle/issues/26091 |
111 | | -//tasks.withType<AbstractPublishToMaven>().configureEach { |
112 | | -// val signingTasks = tasks.withType<Sign>() |
113 | | -// mustRunAfter(signingTasks) |
114 | | -//} |
115 | | -//endregion |
116 | | - |
117 | | - |
118 | | -inline val Project.sourceSets: SourceSetContainer |
119 | | - get() = extensions.getByName("sourceSets") as SourceSetContainer |
120 | | - |
121 | | -internal val TaskContainer.dokkaHtml: TaskProvider<org.jetbrains.dokka.gradle.DokkaTask> |
122 | | - get() = named<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml") |
| 1 | +// import love.forte.gradle.common.core.Gpg |
| 2 | +// import love.forte.gradle.common.publication.configure.configPublishMaven |
| 3 | +// import love.forte.gradle.common.publication.configure.publishingExtension |
| 4 | +// import love.forte.gradle.common.publication.configure.setupPom |
| 5 | +// import love.forte.gradle.common.publication.configure.signingExtension |
| 6 | +// import utils.isMainPublishable |
| 7 | +// |
| 8 | +// plugins { |
| 9 | +// id("signing") |
| 10 | +// id("maven-publish") |
| 11 | +// } |
| 12 | +// |
| 13 | +// //setup(IProject) |
| 14 | +// |
| 15 | +// //val (sonatypeUsername, sonatypePassword) = sonatypeUserInfoOrNull |
| 16 | +// |
| 17 | +// //val sonatypeContains = sonatypeUserInfoOrNull != null |
| 18 | +// val gpgValue = Gpg.ofSystemPropOrNull() |
| 19 | +// |
| 20 | +// // see https://github.com/gradle/gradle/issues/26091#issuecomment-1681343496 |
| 21 | +// |
| 22 | +// val p = project |
| 23 | +// |
| 24 | +// if (isMainPublishable()) { |
| 25 | +// val isSnapshot = project.version.toString().contains("SNAPSHOT") |
| 26 | +// publishingExtension { |
| 27 | +// repositories { |
| 28 | +// mavenLocal() |
| 29 | +// if (isSnapshot) { |
| 30 | +// configPublishMaven(SnapshotRepository) |
| 31 | +// } else { |
| 32 | +// configPublishMaven(ReleaseRepository) |
| 33 | +// } |
| 34 | +// } |
| 35 | +// val jarSources = tasks.register("${p.name}SourceJar", Jar::class) { |
| 36 | +// archiveClassifier.set("sources") |
| 37 | +// from(sourceSets["main"].allSource) |
| 38 | +// } |
| 39 | +// |
| 40 | +// val jarJavadoc = tasks.register("${p.name}JavadocJar", Jar::class) { |
| 41 | +// archiveClassifier.set("javadoc") |
| 42 | +// } |
| 43 | +// |
| 44 | +// publications { |
| 45 | +// create<MavenPublication>("publicationDist") { |
| 46 | +// from(components.getByName("java")) |
| 47 | +// artifact(jarSources) |
| 48 | +// artifact(jarJavadoc) |
| 49 | +// version = p.version.toString() |
| 50 | +// setupPom(p.name, IProject) |
| 51 | +// } |
| 52 | +// } |
| 53 | +// |
| 54 | +// signingExtension { |
| 55 | +// val gpg = gpgValue ?: return@signingExtension |
| 56 | +// |
| 57 | +// val (keyId, secretKey, password) = gpg |
| 58 | +// useInMemoryPgpKeys(keyId, secretKey, password) |
| 59 | +// sign(publishingExtension.publications) |
| 60 | +// } |
| 61 | +// } |
| 62 | +// // jvmConfigPublishing { |
| 63 | +// // project = IProject |
| 64 | +// // isSnapshot = project.version.toString().contains("SNAPSHOT", true) |
| 65 | +// // |
| 66 | +// // val jarSources = tasks.register("${p.name}SourceJar", Jar::class) { |
| 67 | +// // archiveClassifier.set("sources") |
| 68 | +// // from(sourceSets["main"].allSource) |
| 69 | +// // } |
| 70 | +// // |
| 71 | +// // val jarJavadoc = tasks.register("${p.name}JavadocJar", Jar::class) { |
| 72 | +// //// dependsOn(tasks.dokkaHtml) |
| 73 | +// //// from(tasks.dokkaHtml.flatMap { it.outputDirectory }) |
| 74 | +// // archiveClassifier.set("javadoc") |
| 75 | +// // } |
| 76 | +// // |
| 77 | +// // tasks.withType<GenerateModuleMetadata> { |
| 78 | +// // dependsOn(jarSources) |
| 79 | +// // dependsOn(jarJavadoc) |
| 80 | +// // } |
| 81 | +// // |
| 82 | +// // artifact(jarSources) |
| 83 | +// // artifact(jarJavadoc) |
| 84 | +// // |
| 85 | +// // releasesRepository = ReleaseRepository |
| 86 | +// // snapshotRepository = SnapshotRepository |
| 87 | +// // |
| 88 | +// // gpg = gpgValue |
| 89 | +// // } |
| 90 | +// |
| 91 | +// } |
| 92 | +// |
| 93 | +// |
| 94 | +// signing { |
| 95 | +// isRequired = gpgValue != null |
| 96 | +// if (gpgValue != null) { |
| 97 | +// val (keyId, secretKey, password) = gpgValue |
| 98 | +// useInMemoryPgpKeys(keyId, secretKey, password) |
| 99 | +// sign(publishingExtension.publications) |
| 100 | +// } |
| 101 | +// } |
| 102 | +// |
| 103 | +// // TODO see https://github.com/gradle-nexus/publish-plugin/issues/208#issuecomment-1465029831 |
| 104 | +// val signingTasks: TaskCollection<Sign> = tasks.withType<Sign>() |
| 105 | +// tasks.withType<PublishToMavenRepository>().configureEach { |
| 106 | +// mustRunAfter(signingTasks) |
| 107 | +// } |
| 108 | +// // see https://github.com/gradle/gradle/issues/26091#issuecomment-1722947958 |
| 109 | +// //region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies |
| 110 | +// // https://github.com/gradle/gradle/issues/26091 |
| 111 | +// //tasks.withType<AbstractPublishToMaven>().configureEach { |
| 112 | +// // val signingTasks = tasks.withType<Sign>() |
| 113 | +// // mustRunAfter(signingTasks) |
| 114 | +// //} |
| 115 | +// //endregion |
| 116 | +// |
| 117 | +// |
| 118 | +// inline val Project.sourceSets: SourceSetContainer |
| 119 | +// get() = extensions.getByName("sourceSets") as SourceSetContainer |
| 120 | +// |
| 121 | +// internal val TaskContainer.dokkaHtml: TaskProvider<org.jetbrains.dokka.gradle.DokkaTask> |
| 122 | +// get() = named<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml") |
0 commit comments