Skip to content

Commit 308f475

Browse files
committed
Generate the pom after sources and javadoc
1 parent b8ac64a commit 308f475

File tree

1 file changed

+86
-88
lines changed

1 file changed

+86
-88
lines changed

gradle/publishing.gradle

Lines changed: 86 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,112 @@
11
apply plugin: 'maven-publish'
22

3-
afterEvaluate {
4-
task sourceJar(type: Jar) {
5-
archiveClassifier.set('sources')
6-
from sourceSets.main.allJava
7-
}
3+
task sourceJar(type: Jar) {
4+
archiveClassifier.set('sources')
5+
from sourceSets.main.allJava
6+
}
87

9-
task javadocJar(type: Jar, dependsOn: javadoc) {
10-
archiveClassifier.set('javadoc')
11-
from javadoc
12-
}
8+
task javadocJar(type: Jar, dependsOn: javadoc) {
9+
archiveClassifier.set('javadoc')
10+
from javadoc
11+
}
1312

14-
jar.archiveClassifier.set("original")
15-
16-
publishing {
17-
publications {
18-
mavenJava(MavenPublication) { publication ->
19-
artifactId = project.name
20-
artifact sourceJar
21-
artifact javadocJar
22-
23-
artifact project.tasks.jar
24-
artifacts.removeAll { it.classifier == jar.archiveClassifier.get() }
25-
artifact project.tasks.shadowJar
26-
27-
pom.withXml {
28-
def rootNode = asNode()
29-
rootNode.children().last() + {
30-
resolveStrategy = Closure.DELEGATE_FIRST
31-
32-
name project.description
33-
description 'Isolated container management for Java code testing'
34-
url 'https://java.testcontainers.org'
35-
issueManagement {
36-
system 'GitHub'
37-
url 'https://github.com/testcontainers/testcontainers-java/issues'
38-
}
39-
licenses {
40-
license {
41-
name 'MIT'
42-
url 'http://opensource.org/licenses/MIT'
43-
}
44-
}
45-
scm {
46-
url 'https://github.com/testcontainers/testcontainers-java/'
47-
connection 'scm:git:git://github.com/testcontainers/testcontainers-java.git'
48-
developerConnection 'scm:git:ssh://[email protected]/testcontainers/testcontainers-java.git'
13+
jar.archiveClassifier.set("original")
14+
15+
publishing {
16+
publications {
17+
mavenJava(MavenPublication) { publication ->
18+
artifactId = project.name
19+
artifact sourceJar
20+
artifact javadocJar
21+
22+
artifact project.tasks.jar
23+
artifacts.removeAll { it.classifier == jar.archiveClassifier.get() }
24+
artifact project.tasks.shadowJar
25+
26+
pom.withXml {
27+
def rootNode = asNode()
28+
rootNode.children().last() + {
29+
resolveStrategy = Closure.DELEGATE_FIRST
30+
31+
name project.description
32+
description 'Isolated container management for Java code testing'
33+
url 'https://java.testcontainers.org'
34+
issueManagement {
35+
system 'GitHub'
36+
url 'https://github.com/testcontainers/testcontainers-java/issues'
37+
}
38+
licenses {
39+
license {
40+
name 'MIT'
41+
url 'http://opensource.org/licenses/MIT'
4942
}
50-
developers {
51-
developer {
52-
id 'rnorth'
53-
name 'Richard North'
54-
55-
}
43+
}
44+
scm {
45+
url 'https://github.com/testcontainers/testcontainers-java/'
46+
connection 'scm:git:git://github.com/testcontainers/testcontainers-java.git'
47+
developerConnection 'scm:git:ssh://[email protected]/testcontainers/testcontainers-java.git'
48+
}
49+
developers {
50+
developer {
51+
id 'rnorth'
52+
name 'Richard North'
53+
5654
}
5755
}
56+
}
5857

59-
def dependenciesNode = rootNode.appendNode('dependencies')
58+
def dependenciesNode = rootNode.appendNode('dependencies')
6059

61-
def apiDeps = project.configurations.api.resolvedConfiguration.firstLevelModuleDependencies
62-
def providedDeps = project.configurations.provided.resolvedConfiguration.firstLevelModuleDependencies
63-
def newApiDeps = apiDeps - providedDeps
60+
def apiDeps = project.configurations.api.resolvedConfiguration.firstLevelModuleDependencies
61+
def providedDeps = project.configurations.provided.resolvedConfiguration.firstLevelModuleDependencies
62+
def newApiDeps = apiDeps - providedDeps
6463

65-
def addDependencies = { Set<ResolvedDependency> resolvedDependencies, scope ->
66-
for (dependency in resolvedDependencies) {
67-
if (dependency.configuration.startsWith("platform-")) {
68-
continue
64+
def addDependencies = { Set<ResolvedDependency> resolvedDependencies, scope ->
65+
for (dependency in resolvedDependencies) {
66+
if (dependency.configuration.startsWith("platform-")) {
67+
continue
68+
}
69+
dependenciesNode.appendNode('dependency').with {
70+
if (!dependency.moduleGroup || !dependency.moduleName || !dependency.moduleVersion) {
71+
throw new IllegalStateException("Wrong dependency: $dependency")
6972
}
70-
dependenciesNode.appendNode('dependency').with {
71-
if (!dependency.moduleGroup || !dependency.moduleName || !dependency.moduleVersion) {
72-
throw new IllegalStateException("Wrong dependency: $dependency")
73-
}
7473

75-
appendNode('groupId', dependency.moduleGroup)
76-
appendNode('artifactId', dependency.moduleName)
77-
appendNode('version', dependency.moduleVersion)
78-
appendNode('scope', scope)
79-
80-
if (dependency instanceof ModuleDependency && !dependency.excludeRules.empty) {
81-
def excludesNode = appendNode('exclusions')
82-
for (rule in dependency.excludeRules) {
83-
excludesNode.appendNode('exclusion').with {
84-
appendNode('groupId', rule.group)
85-
appendNode('artifactId', rule.module)
86-
}
74+
appendNode('groupId', dependency.moduleGroup)
75+
appendNode('artifactId', dependency.moduleName)
76+
appendNode('version', dependency.moduleVersion)
77+
appendNode('scope', scope)
78+
79+
if (dependency instanceof ModuleDependency && !dependency.excludeRules.empty) {
80+
def excludesNode = appendNode('exclusions')
81+
for (rule in dependency.excludeRules) {
82+
excludesNode.appendNode('exclusion').with {
83+
appendNode('groupId', rule.group)
84+
appendNode('artifactId', rule.module)
8785
}
8886
}
8987
}
9088
}
9189
}
92-
addDependencies(newApiDeps, 'compile')
93-
addDependencies(providedDeps, 'provided')
9490
}
91+
addDependencies(newApiDeps, 'compile')
92+
addDependencies(providedDeps, 'provided')
9593
}
9694
}
9795
}
9896
}
99-
// repositories {
100-
// maven {
101-
// url("https://oss.sonatype.org/service/local/staging/deploy/maven2")
102-
// credentials {
103-
// username = System.getenv("OSSRH_USERNAME")
104-
// password = System.getenv("OSSRH_PASSWORD")
105-
// }
106-
// }
107-
// }
108-
109-
// Ensure the POM file is generated during the build process
97+
98+
task generatePom {
99+
doLast {
100+
publishing.publications.mavenJava.pom.withXml {
101+
asNode()
102+
}
103+
}
104+
}
105+
110106
tasks.build {
111-
dependsOn publishing.publications.mavenJava.publishableFiles
107+
dependsOn sourceJar
108+
dependsOn javadocJar
109+
dependsOn generatePom
112110
}
113111
/*
114112

0 commit comments

Comments
 (0)