summaryrefslogtreecommitdiff
path: root/build.gradle
blob: b89f1b59b31caff29b4bb82095e80f9586bbfa9a (plain) (blame)
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
plugins {
	id 'maven-publish'
	id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
}

subprojects {
	apply plugin: 'java'
	apply plugin: 'maven-publish'
	apply plugin: 'checkstyle'

	repositories {
		mavenLocal()
		mavenCentral()
		maven { url 'https://maven.fabricmc.net/' }
	}

	dependencies {
		implementation 'com.google.guava:guava:32.1.2-jre'
		implementation 'com.google.code.gson:gson:2.10.1'
		implementation 'net.fabricmc:mapping-io:0.5.0'
		
		compileOnly 'org.jetbrains:annotations:24.0.1'

		testImplementation 'junit:junit:4.13.2'
		testImplementation 'org.hamcrest:hamcrest:2.2'
	}

	group = 'cuchaz'
	version = '2.3.3'

	version = version + (System.getenv("GITHUB_ACTIONS") ? "" : "+local")

	java {
		withSourcesJar()
		sourceCompatibility = JavaVersion.VERSION_17
		targetCompatibility = JavaVersion.VERSION_17
	}

	tasks.withType(JavaCompile).configureEach {
		it.options.encoding = "UTF-8"

		it.options.release = 17
	}

	checkstyle {
		configFile = rootProject.file('checkstyle.xml')
		toolVersion = '10.12.4'
	}

	publishing {
		publications {
			"$project.name"(MavenPublication) {
				groupId project.group
				artifactId project.name
				version project.version
				from components.java
			}
		}
	}
}

allprojects {
	publishing {
		repositories {
			mavenLocal()

			def ENV = System.getenv()
			if (ENV.MAVEN_URL) {
				maven {
					url ENV.MAVEN_URL
					credentials {
						username ENV.MAVEN_USERNAME
						password ENV.MAVEN_PASSWORD
					}
				}
			}
		}
	}
}

// A task to ensure that the version being released has not already been released.
task checkVersion {
	doFirst {
		def xml = new URL("https://maven.fabricmc.net/cuchaz/enigma/maven-metadata.xml").text
		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