Skip to content

Commit 391a62f

Browse files
committed
Update buildscript, fix lingering problems
1 parent 4c1bc87 commit 391a62f

12 files changed

Lines changed: 49 additions & 82 deletions

File tree

build.gradle

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313
alias libs.plugins.shadow
1414
}
1515

16-
final projectDisplayName = 'Git Version'
16+
gradleutils.displayName = 'Git Version'
1717
final projectVendor = 'Forge Development LLC'
1818
description = 'Used by MinecraftForge projects to calculate project versions based on Git history.'
1919
base.archivesName = 'gitversion'
@@ -76,10 +76,10 @@ license {
7676
tasks.named('jar', Jar) {
7777
manifest {
7878
attributes([
79-
'Specification-Title' : projectDisplayName,
79+
'Specification-Title' : gradleutils.displayName,
8080
'Specification-Vendor' : projectVendor,
8181
'Specification-Version' : gitversion.info.tag,
82-
'Implementation-Title' : projectDisplayName,
82+
'Implementation-Title' : gradleutils.displayName,
8383
'Implementation-Vendor' : projectVendor,
8484
'Implementation-Version': project.version
8585
], 'net/minecraftforge/gitver/api/')
@@ -102,7 +102,6 @@ tasks.named('shadowJar', ShadowJar) {
102102

103103
changelog {
104104
fromBase()
105-
publishAll = false
106105
}
107106

108107
publishing {
@@ -117,7 +116,7 @@ publishing {
117116
gradleutils.promote(it)
118117

119118
pom { pom ->
120-
name = projectDisplayName
119+
name = gradleutils.displayName
121120
description = project.description
122121

123122
gradleutils.pom.addRemoteDetails(pom)
@@ -132,6 +131,3 @@ publishing {
132131
}
133132
}
134133
}
135-
136-
idea.module { downloadSources = downloadJavadoc = true }
137-
eclipse.classpath { downloadSources = downloadJavadoc = true }

gitversion-gradle/build.gradle

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ plugins {
1717
alias libs.plugins.shadow
1818
}
1919

20-
final projectDisplayName = 'Git Version Gradle Plugin'
20+
gradleutils.displayName = 'Git Version Gradle Plugin'
2121
description = 'A gradle plugin for using Git Version to manage version numbers.'
2222
base.archivesName = 'gitversion-gradle'
2323
group = 'net.minecraftforge'
@@ -29,18 +29,7 @@ java {
2929
withJavadocJar()
3030
}
3131

32-
configurations {
33-
// Applies the "Gradle Plugin API Version" attribute to configuration
34-
// This was added in Gradle 7, gives consumers useful errors if they are on an old version
35-
def applyGradleVersionAttribute = { Configuration configuration ->
36-
configuration.attributes {
37-
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named(GradlePluginApiVersion, libs.versions.gradle.get()))
38-
}
39-
}
40-
41-
named(JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME, applyGradleVersionAttribute)
42-
named(ShadowJavaPlugin.SHADOW_RUNTIME_ELEMENTS_CONFIGURATION_NAME, applyGradleVersionAttribute)
43-
}
32+
gradleutils.pluginDevDefaults(configurations, libs.versions.gradle)
4433

4534
dependencies {
4635
// Static Analysis
@@ -60,15 +49,6 @@ dependencies {
6049
implementation libs.gson
6150
}
6251

63-
// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
64-
// Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
65-
// Shadow: https://github.com/GradleUp/shadow/pull/1422
66-
afterEvaluate { project ->
67-
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly ->
68-
compileOnly.dependencies.remove(project.dependencies.gradleApi())
69-
}
70-
}
71-
7252
license {
7353
header = rootProject.file('../LICENSE-header.txt')
7454
newLine = false
@@ -85,17 +65,8 @@ tasks.named('shadowJar', ShadowJar) {
8565
relocationPrefix = 'net.minecraftforge.gitversion.gradle.shadow'
8666
}
8767

88-
tasks.withType(GroovyCompile).configureEach {
89-
groovyOptions.optimizationOptions.indy = true
90-
}
91-
9268
tasks.withType(Javadoc).configureEach {
9369
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(24) }
94-
95-
options { StandardJavadocDocletOptions options ->
96-
options.windowTitle = projectDisplayName + project.version
97-
options.tags 'apiNote:a:API Note:', 'implNote:a:Implementation Note:'
98-
}
9970
}
10071

10172
changelog {
@@ -110,7 +81,7 @@ gradlePlugin {
11081
plugins.register('gitversion') {
11182
id = 'net.minecraftforge.gitversion'
11283
implementationClass = 'net.minecraftforge.gitversion.gradle.GitVersionPlugin'
113-
displayName = projectDisplayName
84+
displayName = gradleutils.displayName
11485
description = project.description
11586
tags = ['git', 'version']
11687
}
@@ -122,7 +93,7 @@ publishing {
12293
gradleutils.promote(it)
12394

12495
pom { pom ->
125-
name = projectDisplayName
96+
name = gradleutils.displayName
12697
description = project.description
12798

12899
gradleutils.pom.addRemoteDetails(pom)
@@ -141,6 +112,3 @@ publishing {
141112
maven gradleutils.getPublishingForgeMaven(rootProject.file('../repo'))
142113
}
143114
}
144-
145-
idea.module { downloadSources = downloadJavadoc = true }
146-
eclipse.classpath { downloadSources = downloadJavadoc = true }

gitversion-gradle/changelog-gradle/build.gradle

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
alias libs.plugins.shadow
1717
}
1818

19-
final projectDisplayName = 'Git Changelog'
19+
gradleutils.displayName = 'Git Changelog'
2020
description = 'Creates a changelog text file based on git history using GitVersion.'
2121
base.archivesName = 'changelog-gradle'
2222
group = 'net.minecraftforge'
@@ -33,7 +33,7 @@ configurations {
3333
// This was added in Gradle 7, gives consumers useful errors if they are on an old version
3434
def applyGradleVersionAttribute = { Configuration configuration ->
3535
configuration.attributes {
36-
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named(GradlePluginApiVersion, libs.versions.gradle.get()))
36+
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named(GradlePluginApiVersion, gradleutils.unpack(libs.versions.gradle)))
3737
}
3838
}
3939

@@ -82,11 +82,6 @@ tasks.named('shadowJar', ShadowJar) {
8282

8383
tasks.withType(Javadoc).configureEach {
8484
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(24) }
85-
86-
options { StandardJavadocDocletOptions options ->
87-
options.windowTitle = projectDisplayName + project.version
88-
options.tags 'apiNote:a:API Note:', 'implNote:a:Implementation Note:'
89-
}
9085
}
9186

9287
changelog {
@@ -101,7 +96,7 @@ gradlePlugin {
10196
plugins.register('changelog') {
10297
id = 'net.minecraftforge.changelog'
10398
implementationClass = 'net.minecraftforge.gitversion.gradle.changelog.ChangelogPlugin'
104-
displayName = projectDisplayName
99+
displayName = gradleutils.displayName
105100
description = project.description
106101
tags = ['git', 'changelog']
107102
}
@@ -113,7 +108,7 @@ publishing {
113108
gradleutils.promote(it)
114109

115110
pom { pom ->
116-
name = projectDisplayName
111+
name = gradleutils.displayName
117112
description = project.description
118113

119114
gradleutils.pom.addRemoteDetails(pom)
@@ -132,6 +127,3 @@ publishing {
132127
maven gradleutils.getPublishingForgeMaven(rootProject.file('../repo'))
133128
}
134129
}
135-
136-
idea.module { downloadSources = downloadJavadoc = true }
137-
eclipse.classpath { downloadSources = downloadJavadoc = true }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package net.minecraftforge.gitversion.gradle.changelog;
2+
3+
import net.minecraftforge.gradleutils.shared.EnhancedPlugin;
4+
import net.minecraftforge.gradleutils.shared.EnhancedTask;
5+
import org.gradle.api.Project;
6+
7+
interface ChangelogTask extends EnhancedTask<ChangelogProblems> {
8+
@Override
9+
default Class<? extends EnhancedPlugin<? super Project>> pluginType() {
10+
return ChangelogPlugin.class;
11+
}
12+
13+
@Override
14+
default Class<ChangelogProblems> problemsType() {
15+
return ChangelogProblems.class;
16+
}
17+
}

gitversion-gradle/changelog-gradle/src/main/java/net/minecraftforge/gitversion/gradle/changelog/CopyChangelogInternal.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@
44
*/
55
package net.minecraftforge.gitversion.gradle.changelog;
66

7-
import net.minecraftforge.gradleutils.shared.EnhancedPlugin;
8-
import net.minecraftforge.gradleutils.shared.EnhancedTask;
9-
import org.gradle.api.Project;
107
import org.gradle.api.reflect.HasPublicType;
118
import org.gradle.api.reflect.TypeOf;
129
import org.gradle.api.tasks.Internal;
1310

14-
non-sealed interface CopyChangelogInternal extends CopyChangelog, EnhancedTask, HasPublicType {
15-
@Override
16-
default Class<? extends EnhancedPlugin<? super Project>> pluginType() {
17-
return ChangelogPlugin.class;
18-
}
19-
11+
non-sealed interface CopyChangelogInternal extends CopyChangelog, ChangelogTask, HasPublicType {
2012
@Override
2113
default @Internal TypeOf<?> getPublicType() {
2214
return TypeOf.typeOf(CopyChangelog.class);

gitversion-gradle/changelog-gradle/src/main/java/net/minecraftforge/gitversion/gradle/changelog/GenerateChangelogImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import net.minecraftforge.gitversion.gradle.common.GitVersionTools;
88
import net.minecraftforge.gradleutils.shared.ToolExecBase;
9+
import org.gradle.api.file.ProjectLayout;
910
import org.gradle.api.file.RegularFileProperty;
1011
import org.gradle.api.provider.Property;
1112
import org.gradle.api.tasks.Input;
@@ -21,9 +22,11 @@ abstract class GenerateChangelogImpl extends ToolExecBase<ChangelogProblems> imp
2122
@Override public abstract @Input @Optional Property<String> getProjectUrl();
2223
@Override public abstract @Input Property<Boolean> getBuildMarkdown();
2324

25+
protected abstract @Inject ProjectLayout getProjectLayout();
26+
2427
@Inject
2528
public GenerateChangelogImpl() {
26-
super(ChangelogProblems.class, GitVersionTools.GITVERSION);
29+
super(GitVersionTools.GITVERSION);
2730

2831
this.setDescription("Generates a changelog for the project based on the Git history using Git Version.");
2932

gitversion-gradle/changelog-gradle/src/main/java/net/minecraftforge/gitversion/gradle/changelog/GenerateChangelogInternal.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@
44
*/
55
package net.minecraftforge.gitversion.gradle.changelog;
66

7-
import net.minecraftforge.gradleutils.shared.EnhancedPlugin;
8-
import net.minecraftforge.gradleutils.shared.EnhancedTask;
9-
import org.gradle.api.Project;
107
import org.gradle.api.reflect.HasPublicType;
118
import org.gradle.api.reflect.TypeOf;
129
import org.gradle.api.tasks.Internal;
1310

14-
non-sealed interface GenerateChangelogInternal extends GenerateChangelog, EnhancedTask, HasPublicType {
15-
@Override
16-
default Class<? extends EnhancedPlugin<? super Project>> pluginType() {
17-
return ChangelogPlugin.class;
18-
}
19-
11+
non-sealed interface GenerateChangelogInternal extends GenerateChangelog, ChangelogTask, HasPublicType {
2012
@Override
2113
default @Internal TypeOf<?> getPublicType() {
2214
return TypeOf.typeOf(GenerateChangelog.class);

gitversion-gradle/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ org.gradle.configuration-cache.problems=warn
88

99
systemProp.org.gradle.unsafe.suppress-gradle-api=true
1010

11+
net.minecraftforge.gradleutils.ide.automatic.sources=true
12+
net.minecraftforge.gradleutils.compilation.defaults=true
13+
1114
net.minecraftforge.gitversion.log.version=true

gitversion-gradle/settings.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pluginManagement {
22
repositories {
3-
mavenLocal()
3+
//mavenLocal()
44
gradlePluginPortal()
55
maven { url = 'https://maven.minecraftforge.net' }
66
}
@@ -12,7 +12,7 @@ plugins {
1212
// NOTE: We need to load this into the classpath before GradleUtils for the service to load correctly
1313
id 'io.freefair.javadoc-links' version '8.14' apply false // https://plugins.gradle.org/plugin/io.freefair.javadoc-links
1414

15-
id 'net.minecraftforge.gradleutils' version '3.2.20' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
15+
id 'net.minecraftforge.gradleutils' version '3.3.0' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
1616
}
1717

1818
rootProject.name = 'gitversion-gradle'
@@ -32,12 +32,12 @@ dependencyResolutionManagement {
3232
}
3333

3434
versionCatalogs.register('libs') {
35-
version 'gradleutils', '3.2.20'
35+
version 'gradleutils', '3.3.0'
3636

3737
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
3838
plugin 'javadoc-links', 'io.freefair.javadoc-links' version '8.14' // https://plugins.gradle.org/plugin/io.freefair.javadoc-links
39-
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.0.1' // https://plugins.gradle.org/plugin/net.minecraftforge.gitversion
40-
plugin 'changelog', 'net.minecraftforge.changelog' version '3.0.1' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
39+
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.0.7' // https://plugins.gradle.org/plugin/net.minecraftforge.gitversion
40+
plugin 'changelog', 'net.minecraftforge.changelog' version '3.0.6' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
4141
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '1.3.1' // https://plugins.gradle.org/plugin/com.gradle.plugin-publish
4242
plugin 'shadow', 'com.gradleup.shadow' version '9.0.2' // https://plugins.gradle.org/plugin/com.gradleup.shadow
4343

gitversion-gradle/src/main/groovy/net/minecraftforge/gitversion/gradle/GitVersionPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ abstract class GitVersionPlugin extends EnhancedPlugin<ExtensionAware> {
2121

2222
static final Logger LOGGER = Logging.getLogger(GitVersionPlugin.class);
2323

24+
// Used by GitVersionValueSource
2425
@Override protected abstract @Inject ProviderFactory getProviders();
2526

2627
@Inject
@@ -31,7 +32,7 @@ public GitVersionPlugin() {
3132
@Override
3233
public void setup(ExtensionAware target) {
3334
// Gradle 9.0.0 removes the ability to move the settings.gradle file, so it is guaranteed to be the root directory
34-
if (target instanceof Project project && Objects.equals(this.getProjectLayout().getProjectDirectory().getAsFile(), this.getProjectLayout().getSettingsDirectory().getAsFile())) {
35+
if (target instanceof Project project && Objects.equals(this.getProjectLayout().getProjectDirectory().getAsFile(), this.rootProjectDirectory().getAsFile().get())) {
3536
var gitversion = project.getGradle().getExtensions().findByType(GitVersionExtension.class);
3637
if (gitversion != null) {
3738
((GitVersionExtensionInternal) gitversion).attachTo(project);

0 commit comments

Comments
 (0)