Skip to content

Commit 89de4eb

Browse files
authored
Merge pull request #16 from linkedin/rakhi/jFrog
Add LinkedIn JFrog Artifactory publishing and cleanup
2 parents e4032b0 + ad48cdf commit 89de4eb

File tree

7 files changed

+102
-162
lines changed

7 files changed

+102
-162
lines changed

.github/actions/release/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ runs:
1212
shell: bash
1313
- run: echo Got version ${{ steps.get-tag.outputs.tag }}
1414
shell: bash
15-
- run: ./gradlew build -x integrationTest publishToMavenLocal artifactoryPublish -Partifactory.dryRun
15+
- run: ./gradlew build -x integrationTest publishToMavenLocal artifactoryPublish -Partifactory.dryRun --no-configuration-cache
1616
shell: bash
17-
- run: ./gradlew ciPerformRelease
17+
- run: ./gradlew ciPerformRelease --no-configuration-cache
1818
shell: bash

.m2/settings.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<servers>
55
<server>
66
<username>${env.ARTIFACTORY_USER}</username>
7-
<password>$(env.ARTIFACTORY_KEY}</password>
7+
<password>${env.ARTIFACTORY_KEY}</password>
88
<id>central</id>
99
</server>
1010
<server>
1111
<username>${env.ARTIFACTORY_USER}</username>
12-
<password>$(env.ARTIFACTORY_KEY}</password>
12+
<password>${env.ARTIFACTORY_KEY}</password>
1313
<id>snapshots</id>
1414
</server>
1515
</servers>
@@ -22,13 +22,13 @@
2222
</snapshots>
2323
<id>central</id>
2424
<name>release</name>
25-
<url>https://linkedin.jfrog.io/artifactory/release</url>
25+
<url>https://linkedin.jfrog.io/artifactory/ignite</url>
2626
</repository>
2727
<repository>
2828
<snapshots />
2929
<id>snapshots</id>
3030
<name>remote-repos</name>
31-
<url>https://linkedin.jfrog.io/artifactory/remote-repos</url>
31+
<url>https://linkedin.jfrog.io/artifactory/ignite</url>
3232
</repository>
3333
</repositories>
3434
<pluginRepositories>
@@ -38,13 +38,13 @@
3838
</snapshots>
3939
<id>central</id>
4040
<name>release</name>
41-
<url>https://linkedin.jfrog.io/artifactory/release</url>
41+
<url>https://linkedin.jfrog.io/artifactory/ignite</url>
4242
</pluginRepository>
4343
<pluginRepository>
4444
<snapshots />
4545
<id>snapshots</id>
4646
<name>remote-repos</name>
47-
<url>https://linkedin.jfrog.io/artifactory/remote-repos</url>
47+
<url>https://linkedin.jfrog.io/artifactory/ignite</url>
4848
</pluginRepository>
4949
</pluginRepositories>
5050
<id>artifactory</id>

build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ buildscript {
2121
dependencies {
2222
classpath "org.shipkit:shipkit-auto-version:1.1.1"
2323
classpath "org.shipkit:shipkit-changelog:1.1.1"
24+
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.24.5"
2425
}
2526
}
2627
//This need for resolving plugins in buildscripts
@@ -171,10 +172,7 @@ allprojects {
171172
// Apply common configuration to all subprojects
172173
subprojects {
173174
apply plugin: 'base'
174-
175-
// Apply publishing configuration to relevant modules
176-
apply from: "$rootDir/gradle/publishing.gradle"
177-
175+
178176
repositories {
179177
maven {
180178
url = uri('https://repo.maven.apache.org/maven2/')

buildscripts/publishing.gradle

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,88 @@
1616
*/
1717

1818
apply plugin: 'signing'
19+
apply plugin: 'com.jfrog.artifactory'
1920
apply from: "$rootDir/buildscripts/publishing-repos.gradle"
2021

2122
publishing {
2223
publications {
2324
maven(MavenPublication) {
2425
from components.java
26+
// Note: sourcesJar and javadocJar are automatically included via java-core.gradle's
27+
// withSourcesJar() and withJavadocJar() configuration
2528
}
2629
}
2730
}
2831

2932
signing {
3033
sign publishing.publications
3134
}
35+
36+
////////////////////////////////////////////////
37+
// Artifactory publishing
38+
////////////////////////////////////////////////
39+
40+
// Configure Artifactory after evaluation to avoid serialization issues
41+
afterEvaluate {
42+
artifactory {
43+
contextUrl = 'https://linkedin.jfrog.io/artifactory'
44+
publish {
45+
repository {
46+
repoKey = 'ignite'
47+
username = System.getenv('ARTIFACTORY_USER')
48+
password = System.getenv('ARTIFACTORY_KEY')
49+
maven = true
50+
}
51+
52+
defaults {
53+
// Use publication names as strings, not objects
54+
publications('maven')
55+
publishArtifacts = true
56+
publishPom = true
57+
}
58+
}
59+
60+
resolve {
61+
repository {
62+
repoKey = 'release'
63+
username = System.getenv('ARTIFACTORY_USER')
64+
password = System.getenv('ARTIFACTORY_KEY')
65+
maven = true
66+
}
67+
}
68+
}
69+
70+
tasks.named('artifactoryPublish').configure {
71+
skip = project.hasProperty('artifactory.dryRun')
72+
73+
// Always re-run this task, don't use up-to-date checks
74+
outputs.upToDateWhen { false }
75+
76+
doFirst {
77+
if (project.hasProperty('artifactory.dryRun')) {
78+
logger.lifecycle("DRY RUN: Would publish ${project.name} to Artifactory")
79+
} else {
80+
logger.lifecycle("Publishing ${project.name} to Artifactory at https://linkedin.jfrog.io/artifactory")
81+
logger.lifecycle(" Repository: ignite")
82+
logger.lifecycle(" User: ${System.getenv('ARTIFACTORY_USER') ?: 'NOT SET'}")
83+
84+
// Log the actual artifacts being published
85+
def mavenPub = project.publishing.publications.findByName('maven')
86+
if (mavenPub) {
87+
logger.lifecycle(" Artifacts to upload:")
88+
mavenPub.artifacts.each { artifact ->
89+
def file = artifact.file
90+
def size = file.exists() ? String.format("%.2f KB", file.length() / 1024.0) : "N/A"
91+
logger.lifecycle(" - ${file.name} (${size})")
92+
}
93+
}
94+
}
95+
}
96+
97+
doLast {
98+
if (!project.hasProperty('artifactory.dryRun')) {
99+
logger.lifecycle("Completed publishing ${project.name} to Artifactory")
100+
}
101+
}
102+
}
103+
}

gradle/ci-release.gradle

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,28 @@ task verifyArtifactoryProperties {
1717
task artifactoryPublishAll {
1818
description = "Runs 'artifactoryPublish' tasks from all projects"
1919
mustRunAfter "githubRelease" // github release is easier to rollback so we run it first
20+
21+
doFirst {
22+
def publishTasks = []
23+
subprojects.each { subproject ->
24+
if (subproject.tasks.findByName('artifactoryPublish')) {
25+
publishTasks.add(subproject.path)
26+
}
27+
}
28+
println "Publishing ${publishTasks.size()} modules to Artifactory: ${publishTasks}"
29+
}
30+
31+
doLast {
32+
println "All artifacts published to Artifactory"
33+
}
2034
}
2135

22-
allprojects {
23-
tasks.matching { it.name == "artifactoryPublish" }.all {
24-
it.dependsOn verifyArtifactoryProperties
25-
artifactoryPublishAll.dependsOn it
36+
subprojects {
37+
afterEvaluate { project ->
38+
if (project.tasks.findByName('artifactoryPublish')) {
39+
project.tasks.artifactoryPublish.dependsOn rootProject.tasks.verifyArtifactoryProperties
40+
rootProject.tasks.artifactoryPublishAll.dependsOn project.tasks.artifactoryPublish
41+
}
2642
}
2743
}
2844

gradle/java-publishing.gradle

Lines changed: 0 additions & 111 deletions
This file was deleted.

gradle/publishing.gradle

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)