-
Notifications
You must be signed in to change notification settings - Fork 8
/
common.gradle
67 lines (54 loc) · 1.42 KB
/
common.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
//
// This file is to be applied to every subproject.
//
apply plugin: 'java-library'
apply plugin: 'maven-publish'
String mavenGroupId = 'org.openzen.zencode'
String mavenVersion = '0.3.8'
String branchName = (System.getenv('BRANCH_NAME') ?: 'master').replaceAll('[^A-Za-z-_0-9]', '_')
if(!branchName.equalsIgnoreCase('master')) {
mavenVersion = branchName + '-' + mavenVersion
}
if (System.getenv('BUILD_NUMBER') != null) {
mavenVersion += '.' + System.getenv('BUILD_NUMBER')
}
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
repositories {
mavenCentral()
}
dependencies {
}
String mavenArtifactId = name
group = mavenGroupId
version = mavenVersion
task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
publishing {
publications {
maven(MavenPublication) {
groupId = mavenGroupId
artifactId = mavenArtifactId
version = mavenVersion
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}
task createFolders(description: 'Creates the source folders if they do not exist.') doLast {
sourceSets*.allSource*.srcDirs*.each { File srcDir ->
if (!srcDir.isDirectory()) {
println "Creating source folder: ${srcDir}"
srcDir.mkdirs()
}
}
}