forked from FabricMC/stitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
138 lines (119 loc) · 3.24 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
import com.diffplug.gradle.spotless.JavaExtension
plugins {
id "java"
id "java-library"
id "maven-publish"
id 'com.diffplug.spotless' version "6.12.0"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
def ENV = System.getenv()
version = "0.6.4" + (ENV.GITHUB_ACTIONS ? "" : "+local")
group = 'net.legacyfabric'
archivesBaseName = project.name.toLowerCase()
repositories {
mavenCentral()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
}
configurations {
ship
enigma
implementation.extendsFrom ship
compileOnly.extendsFrom enigma
testImplementation.extendsFrom enigma
}
dependencies {
ship 'org.ow2.asm:asm:9.1'
ship 'org.ow2.asm:asm-commons:9.1'
ship 'org.ow2.asm:asm-tree:9.1'
ship 'org.ow2.asm:asm-util:9.1'
ship 'net.fabricmc:tiny-mappings-parser:0.3.0+build.17'
implementation 'com.google.guava:guava:28.0-jre'
compileOnly 'org.jetbrains:annotations:20.1.0'
enigma 'cuchaz:enigma:0.23.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.1'
}
spotless {
format('java', JavaExtension) {
licenseHeaderFile(rootProject.file("HEADER"))
target '**/*.java'
}
}
jar {
manifest {
attributes 'Implementation-Title': 'Stitch',
'Implementation-Version': archiveVersion,
'Main-Class': "net.fabricmc.stitch.Main"
}
}
task allJar(type: Jar) {
from {
configurations.ship.collect {
it.isDirectory() ? it : zipTree(it)
}
}.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
manifest {
attributes 'Implementation-Title': 'Stitch',
'Implementation-Version': archiveVersion,
'Main-Class': "net.fabricmc.stitch.Main"
}
archiveClassifier = 'all'
with jar
}
java {
withSourcesJar()
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) it.options.release = 8
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact(allJar)
}
}
// select the repositories you want to publish to
repositories {
if (ENV.MAVEN_PUBLISH_CREDENTIALS) {
maven {
url "https://repo.legacyfabric.net/repository/legacyfabric"
credentials {
username ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[0]
password ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[1]
}
authentication {
basic(BasicAuthentication)
}
}
}
}
}
test {
useJUnitPlatform()
}
// A task to ensure that the version being released has not already been released.
task checkVersion {
doFirst {
def url = new URL("https://repo.legacyfabric.net/repository/legacyfabric/net/legacyfabric/stitch/maven-metadata.xml")
if (url != null) {
def xml = url.text
if (xml != null && !xml.isEmpty()) {
def metadata = new XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text();
if (versions.contains(version)) {
throw new RuntimeException("${version} has already been released!")
}
}
}
}
}
publish.mustRunAfter checkVersion