1+ import com.blamejared.Properties
2+ import com.blamejared.Versions
3+ import com.blamejared.gradle.mod.utils.GMUtils
4+ import org.gradle.jvm.tasks.Jar
5+ import java.nio.charset.StandardCharsets
6+
7+ plugins {
8+ base
9+ `java- library`
10+ idea
11+ `maven- publish`
12+ }
13+
14+ base.archivesName.set(" ${Properties .NAME } -${project.name.lowercase()} -${Versions .MINECRAFT } " )
15+ version = GMUtils .updatingVersion(Versions .MOD )
16+ group = Properties .GROUP
17+
18+ java {
19+ toolchain.languageVersion.set(JavaLanguageVersion .of(JavaVersion .VERSION_21 .majorVersion))
20+ withSourcesJar()
21+ withJavadocJar()
22+ }
23+
24+ @Suppress(" UnstableApiUsage" )
25+ repositories {
26+ mavenCentral()
27+ maven(" https://maven.blamejared.com/" ) {
28+ name = " BlameJared"
29+ content {
30+ includeGroupAndSubgroups(" com.blamejared" )
31+ includeGroupAndSubgroups(" mezz.jei" )
32+ includeGroupAndSubgroups(" com.faux" )
33+ includeGroupAndSubgroups(" org.openzen" )
34+ }
35+ }
36+ maven(" https://repo.spongepowered.org/repository/maven-public/" ) {
37+ name = " Sponge"
38+ content {
39+ includeGroupAndSubgroups(" org.spongepowered" )
40+ }
41+ }
42+ maven(" https://maven.parchmentmc.org/" ) {
43+ name = " ParchmentMC"
44+ content {
45+ includeGroupAndSubgroups(" org.parchmentmc" )
46+ }
47+ }
48+ }
49+
50+ setOf (" apiElements" , " runtimeElements" , " sourcesElements" , " javadocElements" ).forEach { it: String ->
51+ configurations.getByName(it).outgoing {
52+ capability(" $group :${base.archivesName.get()} :$version " )
53+ capability(" $group :${Properties .MODID } -${project.name} -${Versions .MINECRAFT } :$version " )
54+ capability(" $group :${Properties .MODID } :$version " )
55+ }
56+ publishing.publications {
57+ if (this is MavenPublication ) {
58+ this .suppressPomMetadataWarningsFor(it)
59+ }
60+ }
61+ }
62+
63+ tasks {
64+ named<JavaCompile >(" compileJava" ).configure {
65+ options.encoding = StandardCharsets .UTF_8 .toString()
66+ options.release.set(Versions .JAVA .toInt())
67+ }
68+ named<Javadoc >(" javadoc" ).configure {
69+ options {
70+ encoding = StandardCharsets .UTF_8 .toString()
71+ // Javadoc defines this specifically as StandardJavadocDocletOptions
72+ // but only has a getter for MinimalJavadocOptions, but let's just make sure to be safe
73+ if (this is StandardJavadocDocletOptions ) {
74+ addStringOption(" Xdoclint:none" , " -quiet" )
75+ }
76+ }
77+ }
78+ named<ProcessResources >(" processResources" ).configure {
79+ val properties = mapOf (
80+ " version" to project.version,
81+ " MOD" to Versions .MOD ,
82+ " JAVA" to Versions .JAVA ,
83+ " MINECRAFT" to Versions .MINECRAFT ,
84+ " FABRIC_LOADER" to Versions .FABRIC_LOADER ,
85+ " FABRIC" to Versions .FABRIC ,
86+ " FORGE" to Versions .FORGE ,
87+ " FORGE_LOADER" to Versions .FORGE_LOADER ,
88+ " NEO_FORGE" to Versions .NEO_FORGE ,
89+ " NEO_FORGE_LOADER" to Versions .NEO_FORGE_LOADER ,
90+ " GROUP" to Properties .GROUP ,
91+ " NAME" to Properties .NAME ,
92+ " AUTHOR" to Properties .AUTHOR ,
93+ " MODID" to Properties .MODID ,
94+ " AVATAR" to Properties .AVATAR ,
95+ " CURSE_PROJECT_ID" to Properties .CURSE_PROJECT_ID ,
96+ " CURSE_HOMEPAGE" to Properties .CURSE_HOMEPAGE ,
97+ " MODRINTH_PROJECT_ID" to Properties .MODRINTH_PROJECT_ID ,
98+ " GIT_REPO" to Properties .GIT_REPO ,
99+ " DESCRIPTION" to Properties .DESCRIPTION ,
100+ " ITEM_ICON" to Properties .ITEM_ICON ,
101+ )
102+ inputs.properties(properties)
103+ filesMatching(setOf (" fabric.mod.json" , " META-INF/mods.toml" , " META-INF/neoforge.mods.toml" , " pack.mcmeta" )) {
104+ expand(properties)
105+ }
106+ }
107+ named<Jar >(" jar" ).configure {
108+ from(project.rootProject.file(" LICENSE" ))
109+ manifest {
110+ attributes[" Specification-Title" ] = Properties .NAME
111+ attributes[" Specification-Vendor" ] = Properties .AUTHOR
112+ attributes[" Specification-Version" ] = archiveVersion
113+ attributes[" Implementation-Title" ] = project.name
114+ attributes[" Implementation-Version" ] = archiveVersion
115+ attributes[" Implementation-Vendor" ] = Properties .AUTHOR
116+ attributes[" Built-On-Java" ] = " ${System .getProperty(" java.vm.version" )} (${System .getProperty(" java.vm.vendor" )} )"
117+ attributes[" Build-On-Minecraft" ] = Versions .MINECRAFT
118+ }
119+ }
120+ }
121+
122+ @Suppress(" UnstableApiUsage" )
123+ configurations {
124+ val library = register(" library" )
125+ val lor = register(" localOnlyRuntime" )
126+ getByName(" implementation" ) {
127+ extendsFrom(library.get())
128+ }
129+ getByName(" runtimeClasspath" ).extendsFrom(lor.get())
130+ }
131+
132+ publishing {
133+ publications {
134+ register<MavenPublication >(" mavenJava" ) {
135+ artifactId = base.archivesName.get()
136+ from(components.getByName(" java" ))
137+ }
138+ }
139+ repositories {
140+ maven(System .getenv(" local_maven_url" ) ? : " file://${project.projectDir} /repo" )
141+ }
142+ }
143+
144+ idea {
145+ module {
146+ excludeDirs.addAll(setOf (project.file(" run" ), project.file(" runs" ), project.file(" run_server" ), project.file(" run_client" ), project.file(" run_game_test" )))
147+ }
148+ }
0 commit comments