-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
104 lines (91 loc) · 2.39 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
plugins {
id "java"
id "idea"
id "maven-publish"
}
version = getVersionFromJava()
group = "net.ilexiconn"
archivesBaseName = "magister"
sourceCompatibility = targetCompatibility = "1.6"
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile "com.google.code.gson:gson:2.5"
}
task sourceJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
}
artifacts {
archives sourceJar, javadocJar
}
def configFile = file "secret.properties"
def config = null
if (configFile.exists()) {
configFile.withReader {
def prop = new Properties()
prop.load(it)
config = new ConfigSlurper().parse prop
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId "net.ilexiconn"
artifactId "magister"
version getVersionFromJava()
from components.java
artifact sourceJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
pom.withXml {
asNode().appendNode("url", "https://github.com/iLexiconn/Magister.java")
}
}
}
repositories {
maven {
credentials {
if (config != null) {
username config.username
password config.password
} else {
username ""
password ""
}
}
if (config != null) {
url config.repo
} else {
url ""
}
}
}
}
String getVersionFromJava() {
String major = "0";
String revision = "0";
String patch = "0";
String prefix = "public static final String VERSION = \"";
File file = file("src/main/java/net/ilexiconn/magister/Magister.java")
file.eachLine { String s ->
s = s.trim();
if (s.startsWith(prefix)) {
s = s.substring(prefix.length(), s.length() - 2);
String[] parts = s.split("\\.");
major = parts[0];
revision = parts[1];
patch = parts[2];
}
}
return "$major.$revision.$patch";
}