Skip to content

Commit 607825d

Browse files
committed
Update build to create publishing artifacts (local workaround)
1 parent af91de4 commit 607825d

File tree

3 files changed

+124
-4
lines changed

3 files changed

+124
-4
lines changed

.github/workflows/manual-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
- name: Create Release Package
3737
run: |
3838
mkdir -p release
39-
cp build/libs/*.jar release/
40-
cp build/publications/mavenJava/*pom* release/
41-
cp build/libs/*.sources.jar release/
42-
cp build/libs/*.javadoc.jar release/
39+
cp core/build/libs/*.jar release/
40+
cp core/build/publications/mavenJava/*pom* release/
41+
cp core/build/libs/*.sources.jar release/
42+
cp core/build/libs/*.javadoc.jar release/
4343
4444
- name: Upload Release Artifacts
4545
uses: actions/upload-artifact@v4

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ plugins {
1818
}
1919

2020
apply from: "$rootDir/gradle/ci-support.gradle"
21+
apply from: "$rootDir/gradle/publishing.gradle"
2122
apply plugin: 'com.github.tjni.captainhook'
2223

2324
captainHook {

gradle/publishing.gradle

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,121 @@
1+
apply plugin: 'maven-publish'
2+
3+
task sourceJar(type: Jar) {
4+
archiveClassifier.set('sources')
5+
from sourceSets.main.allJava
6+
}
7+
8+
task javadocJar(type: Jar, dependsOn: javadoc) {
9+
archiveClassifier.set('javadoc')
10+
from javadoc
11+
}
12+
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'
42+
}
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+
54+
}
55+
}
56+
}
57+
58+
def dependenciesNode = rootNode.appendNode('dependencies')
59+
60+
def apiDeps = project.configurations.api.resolvedConfiguration.firstLevelModuleDependencies
61+
def providedDeps = project.configurations.provided.resolvedConfiguration.firstLevelModuleDependencies
62+
def newApiDeps = apiDeps - providedDeps
63+
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")
72+
}
73+
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)
85+
}
86+
}
87+
}
88+
}
89+
}
90+
}
91+
addDependencies(newApiDeps, 'compile')
92+
addDependencies(providedDeps, 'provided')
93+
}
94+
}
95+
}
96+
}
97+
// repositories {
98+
// maven {
99+
// url("https://oss.sonatype.org/service/local/staging/deploy/maven2")
100+
// credentials {
101+
// username = System.getenv("OSSRH_USERNAME")
102+
// password = System.getenv("OSSRH_PASSWORD")
103+
// }
104+
// }
105+
// }
106+
107+
// Ensure the POM file is generated during the build process
108+
tasks.build {
109+
dependsOn publishing.publications.mavenJava.publishableFiles
110+
dependsOn sourceJar
111+
dependsOn javadocJar
112+
}
113+
/*
114+
115+
116+
117+
118+
1119
apply plugin: 'maven-publish'
2120
3121
task sourceJar(type: Jar) {
@@ -103,3 +221,4 @@ publishing {
103221
}
104222
}
105223
}
224+
*/

0 commit comments

Comments
 (0)