Skip to content

Commit 172c19b

Browse files
author
haileyajohnson
authored
Merge pull request #778 from lesserwhirls/pubFix
[5.x]: Fix root publishing script
2 parents c7499ae + 4057888 commit 172c19b

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

gradle/root/fatJars.gradle

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ configurations {
3030
ncIdv
3131
netcdfAll
3232
toolsUI
33-
dap4lib
3433
}
3534

3635
dependencies {
@@ -62,11 +61,6 @@ dependencies {
6261
toolsUI enforcedPlatform(project(':netcdf-java-platform'))
6362
toolsUI project(':uicdm')
6463
toolsUI 'ch.qos.logback:logback-classic'
65-
66-
dap4lib enforcedPlatform(project(':netcdf-java-platform'))
67-
dap4lib project(':dap4:d4core')
68-
dap4lib project(':dap4:d4lib')
69-
dap4lib 'ch.qos.logback:logback-classic'
7064
}
7165

7266
def fatJarTasks = []
@@ -110,17 +104,6 @@ fatJarTasks << tasks.create(name: 'buildToolsUI', type: ShadowJar) {
110104
}
111105
}
112106

113-
fatJarTasks << tasks.create(name: 'buildDap4Lib', type: ShadowJar) {
114-
archiveBaseName = 'dap4lib'
115-
baseName = 'dap4lib'
116-
setArchiveBaseName('dap4lib')
117-
configurations = [project.configurations.dap4lib]
118-
119-
doFirst {
120-
manifest.attributes project(':dap4:d4lib').tasks.jar.manifest.attributes
121-
}
122-
}
123-
124107
// Common configuration.
125108
configure(fatJarTasks) {
126109
dependsOn configurations*.buildDependencies
@@ -154,5 +137,4 @@ artifacts {
154137
archives buildNcIdv
155138
archives buildNetcdfAll
156139
archives buildToolsUI
157-
archives buildDap4Lib
158140
}

gradle/root/publishing.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def createChecksumsTask = tasks.register('createChecksums') {
8282
}
8383
}
8484
}
85-
dependsOn buildDap4Lib, buildNcIdv, buildNetcdfAll, buildToolsUI
85+
dependsOn buildNcIdv, buildNetcdfAll, buildToolsUI
8686
}
8787

8888
def publishFatJarsTask = tasks.register('publishFatJars', PublishToRawRepoTask) {
@@ -105,3 +105,21 @@ def publishFatJarsTask = tasks.register('publishFatJars', PublishToRawRepoTask)
105105
}
106106

107107
publish.dependsOn publishFatJarsTask
108+
109+
// The "publish" tasks for all subprojects require credentials for our Nexus server, which they look for in Gradle
110+
// properties. If those properties (i.e. NEXUS_USERNAME_KEY and NEXUS_PASSWORD_KEY) haven't been provided, the build
111+
// will fail. Therefore, we only want to configure credentials when a "publish" task is part of the execution plan.
112+
// Otherwise, unavailable credentials could cause a build to fail even if we aren't doing any publishing. The
113+
// TaskExecutionGraph allows us to do that.
114+
gradle.taskGraph.whenReady {TaskExecutionGraph taskGraph ->
115+
// This won't find any publishToMavenLocal tasks. Those are of type PublishToMavenLocal
116+
Collection<Task> mavenPublishTasks = taskGraph.allTasks.findAll {
117+
it instanceof PublishToMavenRepository
118+
}
119+
mavenPublishTasks.each {
120+
it.repository.credentials.with {
121+
username = getPropertyOrFailBuild NEXUS_USERNAME_KEY
122+
password = getPropertyOrFailBuild NEXUS_PASSWORD_KEY
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)