Skip to content

Commit

Permalink
Fix Gradle incompatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonlee committed Oct 22, 2022
1 parent bbb2ba9 commit 23ceaef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/main/groovy/io/codearte/gradle/nexus/NexusStagingPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,27 @@ class NexusStagingPlugin implements Plugin<Project> {

//TODO: Extract to separate class
private void tryToDetermineCredentials(Project project, NexusStagingExtension extension) {
project.afterEvaluate {
project.gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
def configure = { Project evaluatedProject ->
evaluatedProject.gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
if (isAnyOfStagingTasksInTaskGraph(taskGraph)) {
tryToGetCredentialsFromUploadArchivesTask(project, extension)
tryToGetCredentialsFromGradleProperties(project, extension)
} else {
project.logger.debug("No staging task will be executed - skipping determination of Nexus credentials")
evaluatedProject.logger.debug("No staging task will be executed - skipping determination of Nexus credentials")
}
}
}
if (project.state.executed) {
configure(project)
} else {
project.afterEvaluate {
configure(project)
}
}
}

private void tryToGetCredentialsImmediately(Project project, NexusStagingExtension extension) {

}

private boolean isAnyOfStagingTasksInTaskGraph(TaskExecutionGraph taskGraph) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class NexusUploadStagingPlugin implements Plugin<Project> {
void configureTaskDependencies(@Nonnull Project project, TaskProvider<PointUploadArchivesToExplicitRepositoryTask> pointUploadArchivesToExplicitRepositoryTask,
TaskProvider<Task> uploadStagingTask) {

project.afterEvaluate { Project evaluatedProject ->
def configure = { Project evaluatedProject
TaskCollection<CreateRepositoryTask> createRepositoryTasks = project.tasks.withType(CreateRepositoryTask)

project.tasks
Expand Down Expand Up @@ -114,6 +114,11 @@ class NexusUploadStagingPlugin implements Plugin<Project> {
createRepositoryTasks*.onlyIf { isInNonSnapshotVersion(project) }
pointUploadArchivesToExplicitRepositoryTask.configure { task -> task.onlyIf { isInNonSnapshotVersion(project) } }
}
if (project.state.executed) {
configure(project)
} else {
project.afterEvaluate(configure)
}
}

private boolean isInNonSnapshotVersion(Project project) {
Expand Down

0 comments on commit 23ceaef

Please sign in to comment.