11plugins {
2- id ' net.minecrell.licenser' version ' 0.4.1'
3- id ' org.ajoberstar.grgit' version ' 3.0.0'
4- id ' com.github.ben-manes.versions' version ' 0.20.0'
5- // id 'com.github.johnrengelman.shadow' version '2.0.4'
2+ id ' dev.gradleplugins.java-gradle-plugin'
3+ id ' idea'
4+ id ' eclipse'
5+ id ' maven-publish'
6+ alias libs. plugins. licenser
7+ alias libs. plugins. gradleutils
68}
79
8- apply plugin : ' java'
9- apply plugin : ' maven-publish'
10- apply plugin : ' eclipse'
10+ final projectDisplayName = ' ForgeGradle'
11+ final projectArtifactId = base. archivesName = project. name // cannot change this
12+ group = ' net.minecraftforge.gradle'
13+ version = gitversion. tagOffset
1114
12- sourceCompatibility = targetCompatibility = ' 1.8' // Need this here so eclipse task generates correctly.
13- compileJava {
14- sourceCompatibility = targetCompatibility = ' 1.8'
15- }
15+ println " Version: $version "
1616
17- group = ' net.minecraftforge.gradle'
18- version = gitVersion()
19- def gitVersion () {
20- def raw = grgit. describe(longDescr : true , tags : true )
21- def desc = (raw == null ? ' unknown-unknown-unknown' : raw). split(' -' ) as List
22- def hash = desc. remove(desc. size() - 1 )
23- def offset = desc. remove(desc. size() - 1 )
24- def tag = desc. join(' -' )
25- def branch = grgit. branch. current(). name
26- return " ${ tag} .${ offset} " // ${t -> if (branch != 'master') t << '-' + branch}"
27- }
28- println (' Version: ' + version + ' Java: ' + System . getProperty(' java.version' ) + ' JVM: ' + System . getProperty(' java.vm.version' ) + ' (' + System . getProperty(' java.vendor' ) + ' ) Arch: ' + System . getProperty(' os.arch' ))
17+ java. toolchain. languageVersion = JavaLanguageVersion . of(8 )
2918
3019sourceSets {
31- common
32- mcp
33- patcher
34- userdev
20+ register( ' common' )
21+ register( ' mcp' )
22+ register( ' patcher' )
23+ register( ' userdev' )
3524}
3625
3726configurations {
38- all {
27+ configureEach {
3928 exclude group : ' org.ow2.asm'
4029 }
41- mcpImplementation. extendsFrom commonImplementation
42- patcherImplementation. extendsFrom commonImplementation
43- userdevImplementation. extendsFrom mcpImplementation
44- 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' )
46+ }
47+
48+ // See settings.gradle for why this is here
49+ repositories {
50+ mavenCentral()
51+ maven gradleutils. forgeMaven
4552}
4653
47- jar {
54+ dependencies {
55+ commonCompileOnly gradleApi(libs. versions. gradle. get())
56+ commonCompileOnly libs. groovy
57+
58+ commonImplementation libs. diff4j
59+ commonImplementation libs. commons. io
60+ commonImplementation libs. lzma
61+ commonImplementation libs. javaxdelta
62+ commonImplementation libs. gson
63+ commonImplementation libs. guava
64+ commonImplementation libs. fastcsv
65+ commonImplementation libs. artifactural
66+ commonImplementation libs. maven. artifact
67+ commonImplementation libs. httpclient
68+ commonImplementation libs. srgutils
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
75+ }
76+
77+ tasks. named(' jar' , Jar ) {
4878 from sourceSets. common. output
4979 from sourceSets. mcp. output
5080 from sourceSets. patcher. output
5181 from sourceSets. userdev. output
5282}
5383
54- repositories {
55- jcenter()
56- maven { url = ' https://maven.minecraftforge.net/' }
57- }
58-
5984license {
60- header = file(' HEADER ' )
85+ header = rootProject . file(' LICENSE-header.txt ' )
6186 ext {
6287 name = ' ForgeGradle'
6388 year = 2018
@@ -68,67 +93,64 @@ license {
6893 exclude ' net/minecraftforge/gradle/common/util/JavaVersionParser.java'
6994}
7095
71- wrapper {
72- gradleVersion = ' 4.9'
73- distributionType = Wrapper.DistributionType . ALL
74- }
96+ gradlePlugin {
97+ website. set gitversion. url
98+ vcsUrl. set gitversion. url + ' .git'
7599
76- dependencies {
77- commonImplementation gradleApi()
78- commonImplementation ' com.cloudbees:diff4j:1.2'
79- commonImplementation ' commons-io:commons-io:2.4'
80- commonImplementation ' com.github.jponge:lzma-java:1.3' // replaces the LZMA binary
81- commonImplementation ' com.nothome:javaxdelta:2.0.1' // GDIFF implementation for BinPatches
82- commonImplementation ' com.google.code.gson:gson:2.8.5'
83- commonImplementation ' com.google.guava:guava:26.0-jre'
84- commonImplementation ' de.siegmar:fastcsv:1.0.2'
85- commonImplementation ' net.minecraftforge:artifactural:1.0.+'
86- commonImplementation ' org.apache.maven:maven-artifact:3.6.0'
87- commonImplementation ' org.apache.httpcomponents:httpclient:4.3.3'
88- commonImplementation ' net.minecraftforge:srgutils:0.2.12'
100+ compatibility {
101+ minimumGradleVersion = libs. versions. gradle. get()
102+ }
89103
90- mcpImplementation sourceSets. common. output
91- patcherImplementation sourceSets. mcp. output
92- patcherImplementation sourceSets. common. output
93- userdevImplementation sourceSets. mcp. output
94- userdevImplementation sourceSets. common. output
95- }
104+ java {
105+ withSourcesJar()
106+ }
96107
97- // Gradle doesn't add it's own source when doing the API. So lets hack it in!
98- import org.gradle.plugins.ide.eclipse.model.*
99- import org.gradle.plugins.ide.eclipse.model.internal.*
100- project. extensions. eclipse. classpath. file. whenMerged { Classpath cp ->
101- def gradleSrc = gradle. gradleHomeDir. absolutePath. replace(File . separator, ' /' ) + ' /src/'
102- cp. entries. each { entry ->
103- if ((entry in AbstractLibrary ) && entry. library. file. name. startsWith(' gradle-' )) {
104- def type = (entry. library. file. name =~ " ^gradle(-(.*))?-(${ gradle.gradleVersion} )" )[0 ][2 ]
105- if (type == ' api' ) type = ' core-api' // Gradle name is different for cores
106- if (type == ' ' ) type = ' core'
107- 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'
108113 }
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' )
109135 }
110136}
111137
112138publishing {
113- publications {
114- mavenJava(MavenPublication ) {
115- from components. java
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+ }
116150 }
117151 }
152+
118153 repositories {
119- maven {
120- if (System . env. MAVEN_USER ) {
121- url ' https://maven.minecraftforge.net/'
122- authentication {
123- basic(BasicAuthentication )
124- }
125- credentials {
126- username = System . env. MAVEN_USER ?: ' not'
127- password = System . env. MAVEN_PASSWORD ?: ' set'
128- }
129- } else {
130- url ' file://' + rootProject. file(' repo' ). getAbsolutePath()
131- }
132- }
154+ maven gradleutils. publishingForgeMaven
133155 }
134- }
156+ }
0 commit comments