-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
156 lines (134 loc) · 4.79 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
plugins {
id 'dev.architectury.loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}
group = project.maven_group
version = project.mod_version
base {
archivesName = project.archives_name
}
repositories {
// Add NeoForged repository.
maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
flatDir {
dir "libs"
}
}
loom {
silentMojangMappingsLicense()
}
dependencies {
minecraft "net.minecraft:minecraft:$project.minecraft_version"
mappings loom.officialMojangMappings()
neoForge "net.neoforged:neoforge:$project.neoforge_version"
modImplementation "libs:l2backpack:3.0.10"
}
processResources {
inputs.property 'version', project.version
filesMatching('META-INF/neoforge.mods.toml') {
expand version: project.version
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}
publishing {
publications {
// Modified by TeaCon
register('release', MavenPublication) {
// noinspection GroovyAssignabilityCheck
from components.java
version = rootProject.mod_version
groupId = rootProject.maven_group
artifactId = "$mod_github_repo-$rootProject.minecraft_version"
pom {
name = mod_github_repo
url = "https://github.com/$mod_github_owner/$mod_github_repo"
licenses {
license {
name = mod_license
url = "https://github.com/$mod_github_owner/$mod_github_repo/blob/HEAD/LICENSE"
}
}
organization {
name = 'TeaConMC'
url = 'https://github.com/teaconmc'
}
developers {
for (mod_author in "$mod_authors".split(',')) {
developer { id = mod_author.trim(); name = mod_author.trim() }
}
}
issueManagement {
system = 'GitHub Issues'
url = "https://github.com/$mod_github_owner/$mod_github_repo/issues"
}
scm {
url = "https://github.com/$mod_github_owner/$mod_github_repo"
connection = "scm:git:git://github.com/$mod_github_owner/${mod_github_repo}.git"
developerConnection = "scm:git:[email protected]:$mod_github_owner/${mod_github_repo}.git"
}
}
}
}
repositories {
// Modified by TeaCon
maven {
name "teacon"
url "s3://maven/"
credentials(AwsCredentials) {
accessKey = System.env.ARCHIVE_ACCESS_KEY
secretKey = System.env.ARCHIVE_SECRET_KEY
}
}
}
}
// Added by TeaCon
tasks.withType(PublishToMavenRepository).configureEach {
if (repository && repository.name == "archive") {
it.onlyIf {
System.env.MAVEN_USERNAME && System.env.MAVEN_PASSWORD
}
}
}
abstract class TeaConDumpPathToGitHub extends DefaultTask {
@Input
abstract Property<String> getPublishName()
@InputFile
abstract RegularFileProperty getTargetFile()
@TaskAction
void dump() {
if (System.env.GITHUB_ACTIONS) {
File theFile = targetFile.getAsFile().get()
def outputFile = new File(System.env.GITHUB_OUTPUT)
// Use the env-specific line separator for maximally possible compatibility
def newLine = System.getProperty('line.separator')
// Write out new env variable for later usage
outputFile << newLine << "artifact_name=${theFile.getName()}"
outputFile << newLine << "artifact_publish_name=${publishName.get()}"
outputFile << newLine << "artifact_path=${theFile.absolutePath}"
}
}
}
// Added by TeaCon
tasks.register("githubActionOutput", TeaConDumpPathToGitHub) { task ->
task.onlyIf { System.env.GITHUB_ACTIONS }
task.getTargetFile().set(jar.archiveFile)
task.getPublishName().set("${jar.archiveBaseName.get()}-${version}.jar")
}