Skip to content

Commit 7b5fda3

Browse files
committed
Fix issues with build.gradle linting
See MinecraftForge/ForgeGradle#984 (comment) I hate JetBrains
1 parent 1414387 commit 7b5fda3

File tree

6 files changed

+145
-136
lines changed

6 files changed

+145
-136
lines changed

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

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
import org.gradle.api.Action;
99
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
1010

11-
import java.io.File;
12-
1311
/// Contains various utilities for working with Gradle scripts.
1412
///
15-
/// [Projects][org.gradle.api.Project] that apply GradleUtils are given [GradleUtilsExtension.ForProject].
16-
public sealed interface GradleUtilsExtension permits GradleUtilsExtensionInternal, GradleUtilsExtension.ForProject {
13+
/// [Projects][org.gradle.api.Project] that apply GradleUtils are given [GradleUtilsExtensionForProject].
14+
public sealed interface GradleUtilsExtension permits GradleUtilsExtensionInternal, GradleUtilsExtensionForProject {
1715
/// The name for this extension.
1816
String NAME = "gradleutils";
1917

@@ -51,125 +49,4 @@ public sealed interface GradleUtilsExtension permits GradleUtilsExtensionInterna
5149
* </code></pre>
5250
*/
5351
Action<MavenArtifactRepository> minecraftLibsMaven = GradleUtilsExtensionInternal.minecraftLibsMaven;
54-
55-
/// The GradleUtils extension for {@linkplain org.gradle.api.Project projects}, which include additional utilities
56-
/// that are only available for them.
57-
///
58-
/// When applied, GradleUtils will
59-
/// - Create a referenceable [PomUtils] instance in [#getPom()].
60-
/// - Register the `generateActionsWorkflow` task to the project for generating a default template GitHub Actions
61-
/// workflow.
62-
/// - Register the `configureTeamCity` task to the project for working with TeamCity CI pipelines.
63-
///
64-
/// @see GradleUtilsExtension
65-
sealed interface ForProject extends GradleUtilsExtension permits GradleUtilsExtensionInternal.ForProject {
66-
/// Utilities for working with a [org.gradle.api.publish.maven.MavenPom] for publishing artifacts.
67-
///
68-
/// @return The POM utilities
69-
/// @see PomUtils
70-
PomUtils getPom();
71-
72-
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)]
73-
/// in a publishing block.
74-
///
75-
/// This closure respects the current project's version in regard to publishing to a release or snapshot
76-
/// repository.
77-
///
78-
/// **Important:** The following environment variables must be set for this to work:
79-
/// - `MAVEN_USER`: Containing the username to use for authentication
80-
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
81-
///
82-
/// The following environment variables are optional:
83-
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
84-
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
85-
///
86-
/// If the required environment variables are not present, the output Maven will be a local folder named `repo`
87-
/// on the root of the [project directory][org.gradle.api.file.ProjectLayout#getProjectDirectory()].
88-
///
89-
/// If the `MAVEN_URL_RELEASE` variable is not set, the Forge releases repository will be used
90-
/// (`https://maven.minecraftforge.net/releases`).
91-
///
92-
/// @return The closure
93-
default Action<MavenArtifactRepository> getPublishingForgeMaven() {
94-
return getPublishingForgeMaven("https://maven.minecraftforge.net/releases");
95-
}
96-
97-
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)]
98-
/// in a publishing block.
99-
///
100-
/// This closure respects the current project's version in regard to publishing to a release or snapshot
101-
/// repository.
102-
///
103-
/// **Important:** The following environment variables must be set for this to work:
104-
/// - `MAVEN_USER`: Containing the username to use for authentication
105-
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
106-
///
107-
/// The following environment variables are optional:
108-
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
109-
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
110-
///
111-
/// If the required environment variables are not present, the output Maven will be a local folder named `repo`
112-
/// on the root of the [project directory][org.gradle.api.file.ProjectLayout#getProjectDirectory()].
113-
///
114-
/// If the `MAVEN_URL_RELEASE` variable is not set, the passed in fallback URL will be used for the release
115-
/// repository.
116-
///
117-
/// @param fallbackPublishingEndpoint The fallback URL for the release repository
118-
/// @return The closure
119-
Action<MavenArtifactRepository> getPublishingForgeMaven(String fallbackPublishingEndpoint);
120-
121-
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)]
122-
/// in a publishing block.
123-
///
124-
/// This closure respects the current project's version in regard to publishing to a release or snapshot
125-
/// repository.
126-
///
127-
/// **Important:** The following environment variables must be set for this to work:
128-
/// - `MAVEN_USER`: Containing the username to use for authentication
129-
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
130-
///
131-
/// The following environment variables are optional:
132-
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
133-
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
134-
///
135-
/// If the required environment variables are not present, the output Maven will be set to the given default
136-
/// folder.
137-
///
138-
/// If the `MAVEN_URL_RELEASE` variable is not set, the passed in fallback URL will be used for the release
139-
/// repository.
140-
///
141-
/// @param fallbackPublishingEndpoint The fallback URL for the release repository
142-
/// @param defaultFolder The default folder if the required maven information is not set
143-
/// @return The closure
144-
default Action<MavenArtifactRepository> getPublishingForgeMaven(String fallbackPublishingEndpoint, File defaultFolder) {
145-
return getPublishingForgeMaven(fallbackPublishingEndpoint, defaultFolder, new File(defaultFolder.getAbsoluteFile().getParentFile(), "snapshots"));
146-
}
147-
148-
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)]
149-
/// in a publishing block.
150-
///
151-
/// This closure respects the current project's version in regard to publishing to a release or snapshot
152-
/// repository.
153-
///
154-
/// **Important:** The following environment variables must be set for this to work:
155-
/// - `MAVEN_USER`: Containing the username to use for authentication
156-
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
157-
///
158-
/// The following environment variables are optional:
159-
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
160-
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
161-
///
162-
/// If the required environment variables are not present, the output Maven will be set to the given default
163-
/// folder.
164-
///
165-
/// If the `MAVEN_URL_RELEASE` variable is not set, the passed in fallback URL will be used for the release
166-
/// repository.
167-
///
168-
/// @param fallbackPublishingEndpoint The fallback URL for the release repository
169-
/// @param defaultFolder The default folder if the required maven information is not set
170-
/// @param defaultSnapshotFolder The default folder for the snapshot repository if the required maven
171-
/// information is not set
172-
/// @return The closure
173-
Action<MavenArtifactRepository> getPublishingForgeMaven(String fallbackPublishingEndpoint, File defaultFolder, File defaultSnapshotFolder);
174-
}
17552
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Copyright (c) Forge Development LLC and contributors
3+
* SPDX-License-Identifier: LGPL-2.1-only
4+
*/
5+
package net.minecraftforge.gradleutils;
6+
7+
import groovy.lang.Closure;
8+
import org.gradle.api.Action;
9+
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
10+
11+
import java.io.File;
12+
13+
/// The GradleUtils extension for [projects][org.gradle.api.Project], which include additional utilities that are only
14+
/// available for them.
15+
///
16+
/// When applied, GradleUtils will
17+
/// - Create a referenceable [PomUtils] instance in [#getPom()].
18+
/// - Register the `generateActionsWorkflow` task to the project for generating a default template GitHub Actions
19+
/// workflow.
20+
/// - Register the `configureTeamCity` task to the project for working with TeamCity CI pipelines.
21+
///
22+
/// @see GradleUtilsExtension
23+
sealed public interface GradleUtilsExtensionForProject extends GradleUtilsExtension permits GradleUtilsExtensionInternal.ForProject {
24+
/// Utilities for working with a [org.gradle.api.publish.maven.MavenPom] for publishing artifacts.
25+
///
26+
/// @return The POM utilities
27+
/// @see PomUtils
28+
PomUtils getPom();
29+
30+
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)] in a
31+
/// publishing block.
32+
///
33+
/// This closure respects the current project's version in regard to publishing to a release or snapshot
34+
/// repository.
35+
///
36+
/// **Important:** The following environment variables must be set for this to work:
37+
/// - `MAVEN_USER`: Containing the username to use for authentication
38+
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
39+
///
40+
/// The following environment variables are optional:
41+
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
42+
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
43+
///
44+
/// If the required environment variables are not present, the output Maven will be a local folder named `repo` on
45+
/// the root of the [project directory][org.gradle.api.file.ProjectLayout#getProjectDirectory()].
46+
///
47+
/// If the `MAVEN_URL_RELEASE` variable is not set, the Forge releases repository will be used
48+
/// (`https://maven.minecraftforge.net/releases`).
49+
///
50+
/// @return The closure
51+
default Action<MavenArtifactRepository> getPublishingForgeMaven() {
52+
return getPublishingForgeMaven("https://maven.minecraftforge.net/releases");
53+
}
54+
55+
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)] in a
56+
/// publishing block.
57+
///
58+
/// This closure respects the current project's version in regard to publishing to a release or snapshot
59+
/// repository.
60+
///
61+
/// **Important:** The following environment variables must be set for this to work:
62+
/// - `MAVEN_USER`: Containing the username to use for authentication
63+
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
64+
///
65+
/// The following environment variables are optional:
66+
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
67+
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
68+
///
69+
/// If the required environment variables are not present, the output Maven will be a local folder named `repo` on
70+
/// the root of the [project directory][org.gradle.api.file.ProjectLayout#getProjectDirectory()].
71+
///
72+
/// If the `MAVEN_URL_RELEASE` variable is not set, the passed in fallback URL will be used for the release
73+
/// repository.
74+
///
75+
/// @param fallbackPublishingEndpoint The fallback URL for the release repository
76+
/// @return The closure
77+
Action<MavenArtifactRepository> getPublishingForgeMaven(String fallbackPublishingEndpoint);
78+
79+
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)] in a
80+
/// publishing block.
81+
///
82+
/// This closure respects the current project's version in regard to publishing to a release or snapshot
83+
/// repository.
84+
///
85+
/// **Important:** The following environment variables must be set for this to work:
86+
/// - `MAVEN_USER`: Containing the username to use for authentication
87+
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
88+
///
89+
/// The following environment variables are optional:
90+
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
91+
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
92+
///
93+
/// If the required environment variables are not present, the output Maven will be set to the given default
94+
/// folder.
95+
///
96+
/// If the `MAVEN_URL_RELEASE` variable is not set, the passed in fallback URL will be used for the release
97+
/// repository.
98+
///
99+
/// @param fallbackPublishingEndpoint The fallback URL for the release repository
100+
/// @param defaultFolder The default folder if the required maven information is not set
101+
/// @return The closure
102+
default Action<MavenArtifactRepository> getPublishingForgeMaven(String fallbackPublishingEndpoint, File defaultFolder) {
103+
return getPublishingForgeMaven(fallbackPublishingEndpoint, defaultFolder, new File(defaultFolder.getAbsoluteFile().getParentFile(), "snapshots"));
104+
}
105+
106+
/// Get a configuring closure to be passed into [org.gradle.api.artifacts.dsl.RepositoryHandler#maven(Closure)] in a
107+
/// publishing block.
108+
///
109+
/// This closure respects the current project's version in regard to publishing to a release or snapshot
110+
/// repository.
111+
///
112+
/// **Important:** The following environment variables must be set for this to work:
113+
/// - `MAVEN_USER`: Containing the username to use for authentication
114+
/// - `MAVEN_PASSWORD`: Containing the password to use for authentication
115+
///
116+
/// The following environment variables are optional:
117+
/// - `MAVEN_URL_RELEASE`: Containing the URL to use for the release repository
118+
/// - `MAVEN_URL_SNAPSHOT`: Containing the URL to use for the snapshot repository
119+
///
120+
/// If the required environment variables are not present, the output Maven will be set to the given default
121+
/// folder.
122+
///
123+
/// If the `MAVEN_URL_RELEASE` variable is not set, the passed in fallback URL will be used for the release
124+
/// repository.
125+
///
126+
/// @param fallbackPublishingEndpoint The fallback URL for the release repository
127+
/// @param defaultFolder The default folder if the required maven information is not set
128+
/// @param defaultSnapshotFolder The default folder for the snapshot repository if the required maven
129+
/// information is not set
130+
/// @return The closure
131+
Action<MavenArtifactRepository> getPublishingForgeMaven(String fallbackPublishingEndpoint, File defaultFolder, File defaultSnapshotFolder);
132+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import static net.minecraftforge.gradleutils.GradleUtilsPlugin.LOGGER
2626
GradleUtilsExtensionImpl() { }
2727

2828
@CompileStatic
29-
@PackageScope static abstract class ForProjectImpl extends GradleUtilsExtensionImpl implements GradleUtilsExtensionInternal.ForProject {
29+
@PackageScope static abstract class ForProject extends GradleUtilsExtensionImpl implements GradleUtilsExtensionInternal.ForProject {
3030
private final Project project
3131

3232
final PomUtils pom
3333

3434
@Inject
35-
ForProjectImpl(Project project) {
35+
ForProject(Project project) {
3636
this.project = project
3737

3838
this.pom = this.objects.newInstance(PomUtilsImpl, project)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ default TypeOf<?> getPublicType() {
3030
repo.setUrl(Constants.MC_LIBS_MAVEN);
3131
};
3232

33-
non-sealed interface ForProject extends GradleUtilsExtensionInternal, GradleUtilsExtension.ForProject, HasPublicType {
33+
non-sealed interface ForProject extends GradleUtilsExtensionInternal, GradleUtilsExtensionForProject, HasPublicType {
3434
@Override
3535
default TypeOf<?> getPublicType() {
36-
return TypeOf.typeOf(GradleUtilsExtension.ForProject.class);
36+
return TypeOf.typeOf(GradleUtilsExtensionForProject.class);
3737
}
3838
}
3939
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public GradleUtilsPlugin() {
2626
@Override
2727
public void setup(ExtensionAware target) {
2828
if (target instanceof Project project)
29-
project.getExtensions().create(GradleUtilsExtension.NAME, GradleUtilsExtensionImpl.ForProjectImpl.class, project);
29+
project.getExtensions().create(GradleUtilsExtension.NAME, GradleUtilsExtensionImpl.ForProject.class, project);
3030
else
3131
target.getExtensions().create(GradleUtilsExtension.NAME, GradleUtilsExtensionImpl.class);
3232
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import org.gradle.api.publish.maven.MavenPom;
99
import org.gradle.api.publish.maven.MavenPomDeveloper;
1010
import org.gradle.api.publish.maven.MavenPomLicense;
11-
import org.jetbrains.annotations.ApiStatus;
1211

1312
import java.util.Map;
1413

15-
/**
16-
* Contains utilities to make working with {@link MavenPom POMs} more ergonomic.
17-
* <p>This can be accessed by {@linkplain org.gradle.api.Project projects} using the
18-
* {@link GradleUtilsExtension.ForProject gradleutils} extension.</p>
19-
*/
14+
/// Contains utilities to make working with [POMs][MavenPom] more ergonomic.
15+
///
16+
/// This can be accessed by [projects][org.gradle.api.Project] using the
17+
/// {@link GradleUtilsExtensionForProject gradleutils} extension.
2018
public sealed interface PomUtils permits PomUtilsInternal {
2119
/// Allows accessing [licenses][Licenses] from buildscripts using `gradleutils.pom.licenses`.
2220
///
@@ -28,6 +26,7 @@ public sealed interface PomUtils permits PomUtilsInternal {
2826
/// that uses one.
2927
///
3028
/// @see #getLicenses()
29+
//@formatter:off
3130
sealed interface Licenses permits PomUtilsInternal.Licenses {
3231
/// @see <a href="https://spdx.org/licenses/Apache-2.0.html">Apache License 2.0 on SPDX</a>
3332
Action<MavenPomLicense> Apache2_0 = PomUtilsInternal.makeLicense("Apache-2.0", "https://www.apache.org/licenses/LICENSE-2.0");
@@ -38,6 +37,7 @@ sealed interface Licenses permits PomUtilsInternal.Licenses {
3837
/// @see <a href="https://spdx.org/licenses/MIT.html">MIT License on SPDX</a>
3938
Action<MavenPomLicense> MIT = PomUtilsInternal.makeLicense("MIT", "https://opensource.org/license/mit/");
4039
}
40+
//@formatter:on
4141

4242
/// Contains several developers within the MinecraftForge organization to reduce needing to manually write them out
4343
/// in each project they contribute to.

0 commit comments

Comments
 (0)