-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
148 lines (125 loc) · 4.08 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
plugins {
id 'java-library'
id 'maven-publish'
id 'io.freefair.lombok' version libs.versions.delombok
}
group = 'it.fulminazzo'
version = '3.2'
allprojects {
this.ext.getParentFromProject = { project ->
return new HashMap<>(project.getProperties()).get("parent")
}
this.ext.getProjectGroupId = {
String groupId = ""
Project tmp = parent
while (tmp != null) {
groupId = "${tmp.name}.${groupId}"
tmp = getParentFromProject(tmp)
}
if (groupId.size() > 0)
groupId = "." + groupId.substring(0, groupId.length() - 1)
return "${rootProject.group}${groupId}"
}
this.ext.getAppropriateJavaVersion = {
if (project.name.isNumber()) {
def module = project.name as Integer
if (module >= 20) return 17
}
return project.name == 'jbukkit' ? 17 : 8
}
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'io.freefair.lombok'
group = "${rootProject.group}"
version = "${rootProject.version}"
repositories {
mavenCentral()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
maven { url = 'https://repo.fulminazzo.it/releases/' }
}
dependencies {
compileOnly libs.lombok
annotationProcessor libs.lombok
compileOnly libs.annotations
annotationProcessor libs.annotations
testCompileOnly libs.annotations
api libs.fulmicollection
api libs.yagl.common
implementation libs.mockito
if (project.name != 'base') api project(':base')
compileOnly platform(libs.junit.platform)
compileOnly 'org.junit.jupiter:junit-jupiter'
testImplementation platform(libs.junit.platform)
testImplementation 'org.junit.jupiter:junit-jupiter'
}
test {
useJUnitPlatform()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(getAppropriateJavaVersion())
}
}
tasks.register('sourcesJar', Jar) {
from sourceSets.main.allSource
archiveClassifier = 'sources'
}
tasks.register('javadocJar', Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
maven(MavenPublication) {
groupId = getProjectGroupId().toLowerCase()
artifactId = "${project.name.toLowerCase()}"
version = "${rootProject.version}"
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
url "https://repo.fulminazzo.it/releases"
credentials {
username = System.getenv("REPO_USERNAME")
password = System.getenv("REPO_PASSWORD")
}
authentication {
basic(BasicAuthentication)
}
}
}
}
}
/**
* Creates a new module from the given MODULE_NUMBER environment variable.
* WARNING: this will OVERWRITE any existing .java file.
*/
tasks.register('generateModule') {
doLast {
def module = System.getenv('MODULE_NUMBER')
if (module == null)
throw new RuntimeException('Invalid usage of task. Specify a "MODULE_NUMBER" environment variable before using generateModule')
ModuleUtils.generateModule(Integer.valueOf(module))
}
}
/**
* Verifies that in every module are absent repetitions of classes.
*/
tasks.register('cleanModules') {
doLast {
def parent = new File(System.getProperty("user.dir"))
def start = 8
do {
ModuleUtils.checkModuleRepetitions(start)
start++
} while (new File(parent, String.valueOf(start)).isDirectory())
}
}
dependencies {
subprojects.forEach { api project(it.path) }
}