-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
118 lines (105 loc) · 3.24 KB
/
build.gradle
File metadata and controls
118 lines (105 loc) · 3.24 KB
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
plugins {
id 'java'
id 'application'
id 'java-gradle-plugin'
id 'maven-publish'
}
group = 'org.moddingx'
java.toolchain.languageVersion = JavaLanguageVersion.of(25)
configurations {
lib
api.extendsFrom lib
libImpl.extendsFrom lib
implementation.extendsFrom libImpl
libResolvable.extendsFrom libImpl
}
sourceSets {
lib {
compileClasspath = configurations.libResolvable
java { srcDirs = [ file('src/main/java') ] }
resources { srcDirs = [ file('src/main/resources') ] }
}
main { // Main source set needs to be plugin source set
java { srcDirs = [ file('src/plugin/java') ] }
resources { srcDirs = [ file('src/plugin/resources') ] }
}
}
repositories {
mavenCentral()
}
dependencies {
lib 'org.ow2.asm:asm:9.9.1'
lib 'org.ow2.asm:asm-tree:9.9.1'
libImpl 'jakarta.annotation:jakarta.annotation-api:3.0.0'
libImpl 'net.sf.jopt-simple:jopt-simple:5.0.4'
implementation sourceSets.lib.output
}
application.mainClass = 'org.moddingx.ljc.Main'
gradlePlugin {
plugins {
plugin {
id = 'org.moddingx.ljc'
implementationClass = 'org.moddingx.ljc.gradle.LjcPlugin'
}
}
}
tasks.named('jar', Jar).configure { task ->
from sourceSets.lib.output
task.manifest {
attributes 'Main-Class': application.mainClass.get()
}
}
var fatJar = tasks.register('fatjar', Jar) { task ->
archiveClassifier = 'fatjar'
manifest = tasks.named('jar', Jar).get().manifest
with tasks.named('jar', Jar).get()
configurations.libResolvable.each { dep ->
task.from(project.zipTree(dep)) {
exclude 'META-INF/MANIFEST.MF', 'META-INF/INDEX.LIST'
exclude 'module-info.class', 'META-INF/versions/*/module-info.class'
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/SIG-*'
exclude 'META-INF/README*', 'META-INF/LICENSE*', 'META-INF/NOTICE*'
exclude 'META-INF/readme*', 'META-INF/license*', 'META-INF/notice*'
duplicatesStrategy DuplicatesStrategy.FAIL
}
task.from(project.zipTree(dep)) {
include 'META-INF', 'META-INF/**', 'module-info.class'
into "META-INF/libraries/${dep.name.replaceAll('\\.jar$', '')}/"
duplicatesStrategy DuplicatesStrategy.FAIL
}
}
}
var sourcesJar = tasks.register('sourcesJar', Jar) {
archiveClassifier = 'sources'
from sourceSets.lib.allSource
from sourceSets.main.allSource
dependsOn tasks.named('classes')
}
tasks.named('build').configure { task ->
task.dependsOn fatJar
task.dependsOn sourcesJar
}
publishing {
publications {
project.afterEvaluate {
pluginMaven {
artifact sourcesJar
pom {
licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
}
}
}
}
repositories {
maven {
name 'moddingx'
url 'https://maven.moddingx.org/release'
credentials(PasswordCredentials)
}
}
}