Skip to content

Commit 8407421

Browse files
committed
Check promotion publication by name and afterEvaluate
1 parent 036e0e2 commit 8407421

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/main/groovy/net/minecraftforge/gradleutils/internal/GradleUtilsExtensionImpl.groovy

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,18 +403,21 @@ import static net.minecraftforge.gradleutils.internal.GradleUtilsPlugin.LOGGER
403403

404404
@Override
405405
TaskProvider<? extends PromotePublication> promote(MavenPublication publication, @Nullable Action<? super PromotePublication> cfg) {
406-
this.project.tasks.register("promote${publication.name.capitalize()}Publication", PromotePublicationImpl, publication).tap { promote ->
406+
var publicationName = publication.name
407+
project.tasks.register("promote${publicationName.capitalize()}Publication", PromotePublicationImpl, publication).tap { promote ->
407408
if (cfg !== null)
408409
promote.configure { cfg.execute(it) }
409410

410-
this.project.tasks.withType(PublishToMavenRepository).configureEach { publish ->
411-
// if the publish task's publication isn't this one and the repo name isn't 'forge', skip
412-
// the name being 'forge' is enforced by gradle utils
413-
if (publish.publication !== publication || publish.repository.name != 'forge')
414-
return
411+
project.afterEvaluate {
412+
it.tasks.withType(PublishToMavenRepository).configureEach { publish ->
413+
// if the publish task's publication isn't this one and the repo name isn't 'forge', skip
414+
// the name being 'forge' is enforced by gradle utils
415+
if (publish.publication === null || publicationName != publish.publication.name || publish.repository.name != 'forge')
416+
return
415417

416-
publish.finalizedBy(promote)
417-
promote.get().mustRunAfter(publish)
418+
publish.finalizedBy(promote)
419+
promote.get().mustRunAfter(publish)
420+
}
418421
}
419422
}
420423
}

0 commit comments

Comments
 (0)