Skip to content

Commit f3d58bd

Browse files
committed
ore: Allow using a gradle property for the default API token as well
1 parent 7eaf0a5 commit f3d58bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ore/src/main/java/org/spongepowered/gradle/ore/internal/OreDeploymentExtensionImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
public class OreDeploymentExtensionImpl implements OreDeploymentExtension {
3838

3939
private static final String DEFAULT_ENDPOINT = "https://ore.spongepowered.org/";
40+
41+
private static final String API_KEY_GRADLE_PROPERTY = "org.spongepowered.ore.apiToken";
4042
private static final String API_KEY_ENVIRONMENT_VARIABLE = "ORE_TOKEN";
4143
private final Property<String> oreEndpoint;
4244
private final Property<String> apiKey;
@@ -46,10 +48,13 @@ public class OreDeploymentExtensionImpl implements OreDeploymentExtension {
4648
@Inject
4749
public OreDeploymentExtensionImpl(final ObjectFactory objects, final ProviderFactory providers) {
4850
this.oreEndpoint = objects.property(String.class)
49-
.convention(OreDeploymentExtensionImpl.DEFAULT_ENDPOINT);
51+
.convention(OreDeploymentExtensionImpl.DEFAULT_ENDPOINT);
5052

5153
this.apiKey = objects.property(String.class)
52-
.convention(providers.environmentVariable(OreDeploymentExtensionImpl.API_KEY_ENVIRONMENT_VARIABLE));
54+
.convention(
55+
providers.gradleProperty(OreDeploymentExtensionImpl.API_KEY_GRADLE_PROPERTY)
56+
.orElse(providers.environmentVariable(OreDeploymentExtensionImpl.API_KEY_ENVIRONMENT_VARIABLE))
57+
);
5358

5459
this.publications = objects.domainObjectContainer(
5560
OrePublication.class,

0 commit comments

Comments
 (0)