11plugins {
2- id ' java-gradle-plugin'
2+ id ' dev.gradleplugins.java-gradle-plugin'
3+ id ' idea'
34 id ' eclipse'
45 id ' maven-publish'
5- id ' org.cadixdev.licenser' version ' 0.5.0'
6- id ' org.ajoberstar.grgit' version ' 4.1.0'
7- id ' com.github.ben-manes.versions' version ' 0.36.0'
8- // id 'com.github.johnrengelman.shadow' version '2.0.4'
6+ alias libs. plugins. licenser
7+ alias libs. plugins. gradleutils
98}
109
11- version = (grgit. describe(longDescr : true , tags : true ) ?: ' unknown-unknown-unknown' ). split(' -' ). with { " ${ it[0]} .${ it[1]} " }
12- println (' Version: ' + version + ' Java: ' + System . getProperty(' java.version' ) + ' JVM: ' + System . getProperty(' java.vm.version' ) + ' (' + System . getProperty(' java.vendor' ) + ' ) Arch: ' + System . getProperty(' os.arch' ))
10+ final projectDisplayName = ' ForgeGradle'
11+ final projectArtifactId = base. archivesName = project. name // cannot change this
12+ group = ' net.minecraftforge.gradle'
13+ version = gitversion. tagOffset
1314
14- sourceSets {
15- common
16- mcp
17- patcher
18- userdev
19- }
15+ println " Version: $version "
2016
2117java. toolchain. languageVersion = JavaLanguageVersion . of(8 )
2218
19+ sourceSets {
20+ register(' common' )
21+ register(' mcp' )
22+ register(' patcher' )
23+ register(' userdev' )
24+ }
25+
2326configurations {
24- all {
27+ configureEach {
2528 exclude group : ' org.ow2.asm'
2629 }
27- mcpImplementation. extendsFrom commonImplementation
28- patcherImplementation. extendsFrom commonImplementation
29- userdevImplementation. extendsFrom mcpImplementation
30- implementation. extendsFrom mcpImplementation, patcherImplementation, userdevImplementation
30+
31+ def extend = { String to , String ... from ->
32+ final SourceSet toSet = sourceSets. getByName(to)
33+
34+ for (var s in from) {
35+ final SourceSet fromSet = sourceSets. getByName(s)
36+
37+ named(toSet. implementationConfigurationName) { extendsFrom getByName(fromSet. implementationConfigurationName) }
38+ named(toSet. compileOnlyConfigurationName) { extendsFrom getByName(fromSet. compileOnlyConfigurationName) }
39+ }
40+ }
41+
42+ extend(' mcp' , ' common' )
43+ extend(' patcher' , ' common' )
44+ extend(' userdev' , ' mcp' )
45+ extend(' main' , ' mcp' , ' patcher' , ' userdev' )
3146}
3247
33- jar {
34- from sourceSets. common. output
35- from sourceSets. mcp. output
36- from sourceSets. patcher. output
37- from sourceSets. userdev. output
48+ // See settings.gradle for why this is here
49+ repositories {
50+ mavenCentral()
51+ maven gradleutils. forgeMaven
3852}
3953
40- task sourcesJar (type : Jar ) {
41- from sourceSets. common. allJava
42- from sourceSets. mcp. allJava
43- from sourceSets. patcher. allJava
44- from sourceSets. userdev. allJava
45- archiveClassifier = ' sources'
54+ dependencies {
55+ commonCompileOnly gradleApi(libs. versions. gradle. get())
56+ commonCompileOnly libs. bundles. groovy
57+
58+ commonImplementation libs. commons. io
59+ commonImplementation libs. lzma
60+ commonImplementation libs. javaxdelta
61+ commonImplementation libs. gson
62+ commonImplementation libs. guava
63+ commonImplementation libs. fastcsv
64+ commonImplementation libs. artifactural
65+ commonImplementation libs. maven. artifact
66+ commonImplementation libs. httpclient
67+ commonImplementation libs. srgutils
68+ commonImplementation variantOf(libs. diffpatch) { classifier ' all' }
69+
70+ mcpImplementation sourceSets. common. output
71+ patcherImplementation sourceSets. mcp. output
72+ patcherImplementation sourceSets. common. output
73+ userdevImplementation sourceSets. mcp. output
74+ userdevImplementation sourceSets. common. output
4675}
4776
48- repositories {
49- mavenLocal()
50- jcenter()
51- maven { url = ' https://maven.minecraftforge.net/ ' }
52- maven { url = ' https://repo.gradle.org/gradle/libs-releases-local/ ' }
77+ tasks . named( ' jar ' , Jar ) {
78+ from sourceSets . common . output
79+ from sourceSets . mcp . output
80+ from sourceSets . patcher . output
81+ from sourceSets . userdev . output
5382}
5483
5584license {
56- header = file(' HEADER ' )
85+ header = rootProject . file(' LICENSE-header.txt ' )
5786 ext {
5887 name = ' ForgeGradle'
5988 year = 2018
@@ -64,67 +93,64 @@ license {
6493 exclude ' net/minecraftforge/gradle/common/util/JavaVersionParser.java'
6594}
6695
67- wrapper {
68- gradleVersion = ' 6.8'
69- distributionType = Wrapper.DistributionType . ALL
70- }
96+ gradlePlugin {
97+ website. set gitversion. url
98+ vcsUrl. set gitversion. url + ' .git'
7199
72- dependencies {
73- commonImplementation gradleApi()
74- commonImplementation ' commons-io:commons-io:2.8.0'
75- commonImplementation ' com.github.jponge:lzma-java:1.3' // replaces the LZMA binary
76- commonImplementation ' com.nothome:javaxdelta:2.0.1' // GDIFF implementation for BinPatches
77- commonImplementation ' com.google.code.gson:gson:2.8.6'
78- commonImplementation ' com.google.guava:guava:30.1-jre'
79- commonImplementation ' de.siegmar:fastcsv:2.0.0'
80- commonImplementation ' net.minecraftforge:artifactural:2.0.3'
81- commonImplementation ' org.apache.maven:maven-artifact:3.6.3'
82- commonImplementation ' org.apache.httpcomponents:httpclient:4.5.13'
83- commonImplementation ' net.minecraftforge:srgutils:0.4.1'
84- commonImplementation ' net.minecraftforge:DiffPatch:2.0.5:all'
100+ compatibility {
101+ minimumGradleVersion = libs. versions. gradle. get()
102+ }
85103
86- mcpImplementation sourceSets. common. output
87- patcherImplementation sourceSets. mcp. output
88- patcherImplementation sourceSets. common. output
89- userdevImplementation sourceSets. mcp. output
90- userdevImplementation sourceSets. common. output
91- }
104+ java {
105+ withSourcesJar()
106+ }
92107
93- // Gradle doesn't add it's own source when doing the API. So lets hack it in!
94- import org.gradle.plugins.ide.eclipse.model.*
95- import org.gradle.plugins.ide.eclipse.model.internal.*
96- project. extensions. eclipse. classpath. file. whenMerged { Classpath cp ->
97- def gradleSrc = gradle. gradleHomeDir. absolutePath. replace(File . separator, ' /' ) + ' /src/'
98- cp. entries. each { entry ->
99- if ((entry in AbstractLibrary ) && entry. library. file. name. startsWith(' gradle-' )) {
100- def type = (entry. library. file. name =~ " ^gradle(-(.*))?-(${ gradle.gradleVersion} )" )[0 ][2 ]
101- if (type == ' api' ) type = ' core-api' // Gradle name is different for cores
102- if (type == ' ' ) type = ' core'
103- entry. sourcePath = new FileReferenceFactory (). fromPath(gradleSrc + type)
108+ plugins {
109+ // UserDev
110+ register(' userdev' ) {
111+ id = ' net.minecraftforge.gradle'
112+ implementationClass = ' net.minecraftforge.gradle.userdev.UserDevPlugin'
104113 }
114+
115+ // MCP
116+ def mcp = { String name ->
117+ register(name) {
118+ it. id = " net.minecraftforge.gradle.${ name.replace('-', '.')} "
119+ it. implementationClass = ' net.minecraftforge.gradle.mcp.MCPPlugin'
120+ }
121+ }
122+ mcp(' mcp' )
123+ mcp(' forgedev-mcp' )
124+
125+ // Patcher
126+ def patcher = { String name ->
127+ register(name) {
128+ it. id = " net.minecraftforge.gradle.${ name.replace('-', '.')} "
129+ it. implementationClass = ' net.minecraftforge.gradle.patcher.PatcherPlugin'
130+ }
131+ }
132+ patcher(' patcher' )
133+ patcher(' forgedev' )
134+ patcher(' forgedev-patcher' )
105135 }
106136}
107137
108138publishing {
109- publications {
110- pluginMaven(MavenPublication ) {
111- artifact sourcesJar
139+ publications. register(' pluginMaven' , MavenPublication ) {
140+ artifactId = projectArtifactId
141+
142+ pom { pom ->
143+ name = projectDisplayName
144+
145+ gradleutils. pom. setGitHubDetails pom
146+
147+ licenses {
148+ license gradleutils.pom.licenses.LGPLv2_1
149+ }
112150 }
113151 }
152+
114153 repositories {
115- maven {
116- if (System . env. MAVEN_USER ) {
117- url ' https://maven.minecraftforge.net/'
118- authentication {
119- basic(BasicAuthentication )
120- }
121- credentials {
122- username = System . env. MAVEN_USER ?: ' not'
123- password = System . env. MAVEN_PASSWORD ?: ' set'
124- }
125- } else {
126- url ' file://' + rootProject. file(' repo' ). getAbsolutePath()
127- }
128- }
154+ maven gradleutils. publishingForgeMaven
129155 }
130156}
0 commit comments