Skip to content

Commit d407526

Browse files
committed
Added comments
1 parent 1d22e75 commit d407526

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,18 @@ subprojects {
113113
publishing {
114114
repositories {
115115
maven {
116+
// Snapshot uses a different repository than release.
117+
// The publish in that case will upload to Maven Central snapshot repository.
116118
if (version.endsWith('SNAPSHOT')) {
117119
url = 'https://central.sonatype.com/repository/maven-snapshots/'
118120
credentials {
119121
username = System.getenv("MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME")
120122
password = System.getenv("MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD")
121123
}
122124
} else {
125+
// For releases, the publish task does not upload to MavenCentral.
126+
// It just the artifacts directory hierarchy on the local disk,
127+
// The actual zipping and uploading is done in the publishToMavenCentral task.
123128
url = "${buildDir}/local-repo"
124129
}
125130
}
@@ -167,6 +172,10 @@ subprojects {
167172

168173

169174
tasks.register('publishToMavenCentral') {
175+
// We want to do call the publish task only if the version is a release (ie not a snapshot).
176+
// Without this conditional, with a snapshot it would do the publish first, then throw the Exception below.
177+
// But since the dependsOn is within the conditional, the dependency is not created for snapshot versions
178+
// so the publish in that case is never executed.
170179
if (!version.toString().endsWith('SNAPSHOT')) {
171180
dependsOn tasks.publish
172181
}
@@ -186,6 +195,10 @@ subprojects {
186195
}
187196

188197
tasks.register('publishToSnapshotRepository') {
198+
// We want to do call the publish task only if the version is a snapshot.
199+
// Without this conditional, with a release it would do the publish first, then throw the Exception below.
200+
// But since the dependsOn is within the conditional, the dependency is not created for release versions
201+
// so the publish in that case is never executed.
189202
if (version.toString().endsWith('SNAPSHOT')) {
190203
dependsOn tasks.publish
191204
}

0 commit comments

Comments
 (0)