summaryrefslogtreecommitdiff
path: root/build.gradle
diff options
context:
space:
mode:
authorGravatar modmuss502022-09-14 13:12:55 +0100
committerGravatar GitHub2022-09-14 13:12:55 +0100
commit9c736848fb7aa82d295b3aa2946e6cd132ee998f (patch)
treeb982613cfa7201b2db25cb64a5950f9a2c34a5b3 /build.gradle
parentNested packages in Swing UI (#458) (diff)
downloadenigma-9c736848fb7aa82d295b3aa2946e6cd132ee998f.tar.gz
enigma-9c736848fb7aa82d295b3aa2946e6cd132ee998f.tar.xz
enigma-9c736848fb7aa82d295b3aa2946e6cd132ee998f.zip
Add checkstyle (#460)
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle156
1 files changed, 81 insertions, 75 deletions
diff --git a/build.gradle b/build.gradle
index 80cbd094..782d7ec5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,89 +1,95 @@
1plugins { 1plugins {
2 id 'maven-publish' 2 id 'maven-publish'
3} 3}
4 4
5subprojects { 5subprojects {
6 apply plugin: 'java' 6 apply plugin: 'java'
7 apply plugin: 'maven-publish' 7 apply plugin: 'maven-publish'
8 8 apply plugin: 'checkstyle'
9 sourceCompatibility = JavaVersion.VERSION_17 9
10 targetCompatibility = JavaVersion.VERSION_17 10 sourceCompatibility = JavaVersion.VERSION_17
11 11 targetCompatibility = JavaVersion.VERSION_17
12 repositories { 12
13 mavenLocal() 13 repositories {
14 mavenCentral() 14 mavenLocal()
15 maven { url 'https://maven.fabricmc.net/' } 15 mavenCentral()
16 } 16 maven { url 'https://maven.fabricmc.net/' }
17 17 }
18 dependencies { 18
19 implementation 'com.google.guava:guava:30.1.1-jre' 19 dependencies {
20 implementation 'com.google.code.gson:gson:2.8.7' 20 implementation 'com.google.guava:guava:30.1.1-jre'
21 21 implementation 'com.google.code.gson:gson:2.8.7'
22 testImplementation 'junit:junit:4.13.2' 22
23 testImplementation 'org.hamcrest:hamcrest:2.2' 23 testImplementation 'junit:junit:4.13.2'
24 } 24 testImplementation 'org.hamcrest:hamcrest:2.2'
25 25 }
26 group = 'cuchaz' 26
27 version = '2.1.0' 27 group = 'cuchaz'
28 28 version = '2.1.1'
29 version = version + (System.getenv("GITHUB_ACTIONS") ? "" : "+local") 29
30 30 version = version + (System.getenv("GITHUB_ACTIONS") ? "" : "+local")
31 task sourcesJar(type: Jar, dependsOn: classes) { 31
32 classifier = 'sources' 32 task sourcesJar(type: Jar, dependsOn: classes) {
33 from sourceSets.main.allSource 33 classifier = 'sources'
34 } 34 from sourceSets.main.allSource
35 35 }
36 java { 36
37 withSourcesJar() 37 java {
38 } 38 withSourcesJar()
39 39 }
40 tasks.withType(JavaCompile).configureEach { 40
41 it.options.encoding = "UTF-8" 41 tasks.withType(JavaCompile).configureEach {
42 42 it.options.encoding = "UTF-8"
43 it.options.release = 17 43
44 } 44 it.options.release = 17
45 45 }
46 publishing { 46
47 publications { 47 checkstyle {
48 "$project.name"(MavenPublication) { 48 configFile = rootProject.file('checkstyle.xml')
49 groupId project.group 49 toolVersion = '10.3.3'
50 artifactId project.name 50 }
51 version project.version 51
52 from components.java 52 publishing {
53 } 53 publications {
54 } 54 "$project.name"(MavenPublication) {
55 } 55 groupId project.group
56 artifactId project.name
57 version project.version
58 from components.java
59 }
60 }
61 }
56} 62}
57 63
58allprojects { 64allprojects {
59 publishing { 65 publishing {
60 repositories { 66 repositories {
61 mavenLocal() 67 mavenLocal()
62 68
63 def ENV = System.getenv() 69 def ENV = System.getenv()
64 if (ENV.MAVEN_URL) { 70 if (ENV.MAVEN_URL) {
65 maven { 71 maven {
66 url ENV.MAVEN_URL 72 url ENV.MAVEN_URL
67 credentials { 73 credentials {
68 username ENV.MAVEN_USERNAME 74 username ENV.MAVEN_USERNAME
69 password ENV.MAVEN_PASSWORD 75 password ENV.MAVEN_PASSWORD
70 } 76 }
71 } 77 }
72 } 78 }
73 } 79 }
74 } 80 }
75} 81}
76 82
77// A task to ensure that the version being released has not already been released. 83// A task to ensure that the version being released has not already been released.
78task checkVersion { 84task checkVersion {
79 doFirst { 85 doFirst {
80 def xml = new URL("https://maven.fabricmc.net/cuchaz/enigma/maven-metadata.xml").text 86 def xml = new URL("https://maven.fabricmc.net/cuchaz/enigma/maven-metadata.xml").text
81 def metadata = new XmlSlurper().parseText(xml) 87 def metadata = new XmlSlurper().parseText(xml)
82 def versions = metadata.versioning.versions.version*.text(); 88 def versions = metadata.versioning.versions.version*.text();
83 if (versions.contains(version)) { 89 if (versions.contains(version)) {
84 throw new RuntimeException("${version} has already been released!") 90 throw new RuntimeException("${version} has already been released!")
85 } 91 }
86 } 92 }
87} 93}
88 94
89publish.mustRunAfter checkVersion 95publish.mustRunAfter checkVersion