Skip to content

Commit 52bf6e4

Browse files
committed
Allow promotion task to be configured
1 parent 7ec98a8 commit 52bf6e4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtensionForProject.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package net.minecraftforge.gradleutils;
66

7+
import org.gradle.api.Action;
78
import org.gradle.api.publish.maven.MavenPublication;
89
import org.gradle.api.tasks.TaskProvider;
910

@@ -19,5 +20,19 @@ public sealed interface GradleUtilsExtensionForProject extends GradleUtilsExtens
1920
///
2021
/// @param publication The publication to promote
2122
/// @return The provider for the promotion task
22-
TaskProvider<? extends PromotePublication> promote(MavenPublication publication);
23+
default TaskProvider<? extends PromotePublication> promote(MavenPublication publication) {
24+
return this.promote(publication, null);
25+
}
26+
27+
/// Promotes a publication to the <a href="https://files.minecraftforge.net">Forge Files Site</a>.
28+
///
29+
/// Publications that are promoted will automatically have the relevant task added as a finalizer to the
30+
/// `publishPublicationToForgeRepository` task, where the publication matches the task's publication and the
31+
/// repository name is "forge". The publishing Forge repo added via [GradleUtilsExtension#getPublishingForgeMaven]
32+
/// always sets it with the name "forge".
33+
///
34+
/// @param publication The publication to promote
35+
/// @param cfg A configuring action for the task
36+
/// @return The provider for the promotion task
37+
TaskProvider<? extends PromotePublication> promote(MavenPublication publication, Action<? super PromotePublication> cfg);
2338
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
2323
import org.gradle.api.tasks.TaskProvider
2424
import org.gradle.authentication.http.BasicAuthentication
2525
import org.gradle.initialization.layout.BuildLayout
26+
import org.jetbrains.annotations.Nullable
2627

2728
import javax.inject.Inject
2829

@@ -129,8 +130,11 @@ import static net.minecraftforge.gradleutils.GradleUtilsPlugin.LOGGER
129130
}
130131

131132
@Override
132-
TaskProvider<? extends PromotePublication> promote(MavenPublication publication) {
133+
TaskProvider<? extends PromotePublication> promote(MavenPublication publication, @Nullable Action<? super PromotePublication> cfg) {
133134
this.project.tasks.register('promote' + publication.name.capitalize(), PromotePublicationImpl).tap { promote ->
135+
if (cfg !== null)
136+
promote.configure { cfg.execute(it) }
137+
134138
this.project.tasks.withType(PublishToMavenRepository).configureEach { publish ->
135139
// if the publish task's publication isn't this one and the repo name isn't 'forge', skip
136140
// the name being 'forge' is enforced by gradle utils

0 commit comments

Comments
 (0)