-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
195 lines (170 loc) · 4.93 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
plugins {
id 'java'
id 'java-library'
id 'eclipse'
id 'maven-publish'
id 'org.quiltmc.gradle.licenser' version '2.0.1'
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
withJavadocJar()
withSourcesJar()
}
archivesBaseName = "quilt-mod-spec"
version = project.quilt_mod_spec
def ENV = System.getenv()
apply plugin: 'java-library'
apply plugin: 'eclipse'
if (ENV.SNAPSHOTS_URL) {
version = version + "-SNAPSHOT"
}
if (!ENV.GITHUB_ACTIONS) {
version = version + "+local"
}
task classes17(type: Jar) {
archiveClassifier = 'java17'
}
task sources17(type: Jar) {
archiveClassifier = 'java17-sources'
}
configurations {
forJava17 {
canBeConsumed = true
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JavaVersion.VERSION_17.majorVersion.toInteger())
}
outgoing {
variants {
classes {
artifact(tasks["classes17"].archiveFile)
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, 'jar'))
}
}
sources {
artifact(tasks["sources17"].archiveFile)
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, 'sources'))
}
}
}
}
}
}
repositories {
maven {
name = 'Quilt'
url = 'https://maven.quiltmc.org/repository/release'
}
mavenCentral()
}
dependencies {
compileOnly "org.jetbrains:annotations:${project.annotations}"
api "org.quiltmc.parsers:json:${project.quilt_parsers}"
}
org.quiltmc.mod_spec.build.SourceGenerator.generate(rootProject);
test {
useJUnitPlatform()
}
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}
javadoc {
javadocTool.set javaToolchains.javadocToolFor {
languageVersion = JavaLanguageVersion.of(17)
}
options {
if (file("README.html").exists()) {
overview = "README.html"
}
destinationDir = file("${buildDir}/docs/${project.version}")
source = "8"
encoding = 'UTF-8'
charSet = 'UTF-8'
memberLevel = JavadocMemberLevel.PACKAGE
splitIndex true
links(
'https://docs.oracle.com/javase/8/docs/api/'
)
addBooleanOption 'Xdoclint:html', true
addBooleanOption 'Xdoclint:syntax', true
addBooleanOption 'Xdoclint:reference', true
addBooleanOption 'Xdoclint:accessibility', true
addStringOption("-notimestamp")
addStringOption("Xdoclint:none")
addStringOption("-quiet")
addFileOption "-add-stylesheet", file("src/main/javadoc/style.css")
}
source sourceSets.main.allJava.srcDirs
classpath = sourceSets.main.compileClasspath + sourceSets.main.output // compile impl stuff for dep as well
include("**/api/**")
// workaround as one of the api stuff use that package
failOnError false
}
license {
rule project.rootProject.file("codeformat/HEADER")
include '**/*.java'
}
// This is necessary, as otherwise the sourceSets bit grabs *this* source set, not the subproject!
gradle.projectsEvaluated({
jar {
into('META-INF/versions/17') {
from project(':quilt-mod-spec-java17').sourceSets.main.output
}
manifest.attributes('Multi-Release': 'true')
}
classes17 {
duplicatesStrategy = 'exclude'
from project(':quilt-mod-spec-java17').sourceSets.main.output
from sourceSets.main.output
}
sources17 {
duplicatesStrategy = 'exclude'
from project(':quilt-mod-spec-java17').sourceSets.main.allSource
from sourceSets.main.allSource
}
})
AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.components.findByName("java")
javaComponent.addVariantsFromConfiguration(configurations.forJava17) {
// dependencies for this variant are considered runtime dependencies
it.mapToMavenScope("compile")
}
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
from components.java
}
}
repositories {
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
} else if (ENV.SNAPSHOTS_URL) {
maven {
url ENV.SNAPSHOTS_URL
credentials {
username ENV.SNAPSHOTS_USERNAME
password ENV.SNAPSHOTS_PASSWORD
}
}
} else {
mavenLocal()
}
}
}