11plugins {
2- id " dev.architectury.loom " version " 1.2-SNAPSHOT "
2+ id ' idea '
33 id ' maven-publish'
4- id " com.matthewprenger.cursegradle" version " 1.4.0"
4+ id ' net.minecraftforge.gradle' version ' [6.0.16,6.2)'
5+ id " me.modmuss50.mod-publish-plugin" version " 0.4.5"
6+ id ' org.spongepowered.mixin' version ' 0.7.+'
57}
68
7- sourceCompatibility = targetCompatibility = compileJava . sourceCompatibility = compileJava . targetCompatibility = 17
9+ java . toolchain . languageVersion = JavaLanguageVersion . of( 17 )
810
9- def ENV = System . getenv()
10- version = " ${ minecraft_version} -${ mod_version} -build.${ ENV.GITHUB_RUN_NUMBER ?: 9999} "
11- group= " pro.mikey"
12- archivesBaseName = " advanced-xray-forge"
11+ version = mod_version
12+ group = ' pro.mikey'
1313
14- loom {
15- silentMojangMappingsLicense()
16-
17- forge {
18- }
14+ base {
15+ archivesName = " advanced-xray-forge"
16+ }
1917
20- accessWidenerPath = file(" src/main/resources/xray.accesswidener" )
18+ mixin {
19+ add sourceSets. main, ' xray.mixins.refmap.json'
20+ config ' xray.mixins.json'
2121}
2222
23- repositories {
23+ minecraft {
24+ mappings channel : " official" , version : minecraft_version
25+
26+ copyIdeResources = true
27+ // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
28+ accessTransformer = file(' src/main/resources/META-INF/accesstransformer.cfg' )
29+
30+ runs {
31+ // applies to all the run configs below
32+ configureEach {
33+ workingDirectory project. file(' run' )
34+
35+ property ' forge.logging.markers' , ' REGISTRIES'
36+ property ' forge.logging.console.level' , ' debug'
37+
38+ mods {
39+ " ${ mod_id} " {
40+ source sourceSets. main
41+ }
42+ }
43+ }
44+
45+ client {
46+ property ' forge.enabledGameTestNamespaces' , mod_id
47+ }
48+
49+ server {
50+ property ' forge.enabledGameTestNamespaces' , mod_id
51+ args ' --nogui'
52+ }
53+
54+ gameTestServer {
55+ property ' forge.enabledGameTestNamespaces' , mod_id
56+ }
57+
58+ data {
59+ workingDirectory project. file(' run-data' )
60+ args ' --mod' , mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ), ' --existing' , file(' src/main/resources/' )
61+ }
62+ }
2463}
2564
65+ sourceSets. main. resources { srcDir ' src/generated/resources' }
66+
2667def replaceProperties = [
2768 minecraft_version : minecraft_version,
2869 minecraft_version_range : minecraft_version_range. replace(" [%base]" , minecraft_version),
@@ -40,10 +81,14 @@ processResources {
4081}
4182
4283dependencies {
43- minecraft " com.mojang:minecraft:${ project.minecraft_version} "
44- mappings loom. officialMojangMappings()
84+ minecraft " net.minecraftforge:forge:${ minecraft_version} -${ forge_version} "
85+ annotationProcessor ' org.spongepowered:mixin:0.8.5:processor'
86+ }
4587
46- forge " net.minecraftforge:forge:${ project.minecraft_version} -${ project.forge_version} "
88+ repositories {
89+ maven {
90+ url " https://maven.saps.dev/mirror"
91+ }
4792}
4893
4994compileJava {
@@ -54,56 +99,75 @@ java {
5499 withSourcesJar()
55100}
56101
57- jar {
58- from(" LICENSE" ) {
59- rename { " ${ it} _${ project.archivesBaseName} " }
60- }
61-
102+ tasks. named(' jar' , Jar ). configure {
62103 manifest {
63104 attributes([
64- " Specification-Title" : " Advanced XRay" ,
65- " Specification-Vendor" : " Advanced XRay" ,
66- " Specification-Version" : " 1 " ,
67- " Implementation-Title" : " Advanced XRay " ,
68- " Implementation-Version" : version ,
69- " Implementation-Vendor" : " Advanced XRay" ,
70- " Implementation-Timestamp" : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
105+ ' Specification-Title' : " Advanced XRay" ,
106+ ' Specification-Vendor' : " Advanced XRay Team " ,
107+ ' Specification-Version' : ' 1 ' , // We are version 1 of ourselves
108+ ' Implementation-Title' : project . name ,
109+ ' Implementation-Version' : project . jar . archiveVersion ,
110+ ' Implementation-Vendor' : " Advanced XRay Team " ,
111+ ' Implementation-Timestamp' : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
71112 ])
72113 }
114+
115+ finalizedBy ' reobfJar'
73116}
74117
75118publishing {
76119 publications {
77120 mavenJava(MavenPublication ) {
78121 artifactId = rootProject. archivesBaseName
79- from components . java
122+ artifact jar
80123 }
81124 }
82125
83126 repositories {
84- if (ENV . SAPS_TOKEN ) {
127+ def token = providers. environmentVariable(" SAPS_TOKEN" );
128+ if (token. isPresent()) {
85129 maven {
86130 url " https://maven.saps.dev/releases"
87131 credentials {
88132 username = " mikeymods"
89- password = " ${ ENV.SAPS_TOKEN } "
133+ password = token . get()
90134 }
91135 }
92136 }
93137 }
94138}
95139
96- if (ENV . CURSE_DEPLOY_TOKEN ) {
140+ publishMods {
141+ dryRun = providers. environmentVariable(" CURSE_DEPLOY_TOKEN" ). getOrNull() == null
142+ changelog = file(" ./CHANGELOG.md" ). text
143+ version = " ${ mod_version} "
144+ type = STABLE
145+
97146 curseforge {
98- apiKey = ENV . CURSE_DEPLOY_TOKEN
99- project {
100- id = project. curse_id
101- releaseType = " release"
102- addGameVersion " Forge"
103- addGameVersion " $minecraft_version "
104- changelog = file(" ./CHANGELOG.md" )
105- changelogType = ' markdown'
106- mainArtifact(remapJar)
107- }
147+ accessToken = providers. environmentVariable(" CURSE_DEPLOY_TOKEN" )
148+ projectId = " ${ curse_id} "
149+ minecraftVersions. add(" ${ minecraft_version} " )
150+ modLoaders. add(" forge" )
151+ displayName = " [FORGE] [${ minecraft_version} ] ${ project.name} ${ mod_version} "
152+ file = project. tasks. jar. archiveFile
108153 }
154+
155+ github {
156+ accessToken = providers. environmentVariable(" GITHUB_TOKEN" )
157+ repository = " AdvancedXRay/XRay-Mod"
158+ commitish = providers. environmentVariable(" GITHUB_SHA" ). orElse(" dryRun" )
159+ tagName = providers. environmentVariable(" GITHUB_REF_NAME" ). orElse(" dryRun" )
160+
161+ file = project. tasks. jar. archiveFile
162+ }
163+ }
164+
165+ sourceSets. each {
166+ def dir = layout. buildDirectory. dir(" sourcesSets/$it . name " )
167+ it. output. resourcesDir = dir
168+ it. java. destinationDirectory = dir
169+ }
170+
171+ tasks. register(" idePostSync" ) {
172+
109173}
0 commit comments