Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Gradle incompatibility issue #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 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,23 @@ 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 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