-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
73 lines (60 loc) · 1.63 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
plugins {
id 'net.researchgate.release' version '2.4.0'
}
apply plugin: 'java'
apply plugin: 'maven'
group = 'net.zomis'
description = "Minesweeper Analyze"
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
configurations {
deployerJars
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.2'
}
release {
versionPropertyFile = 'gradle.properties'
}
jar {
from sourceSets.main.output
from sourceSets.main.allSource
}
def getMavenSettingsCredentials() {
String userHome = System.getProperty('user.home')
File mavenSettings = new File(userHome, '.m2/settings.xml')
if (!mavenSettings.exists()) {
return []
}
def xmlSlurper = new XmlSlurper()
def output = xmlSlurper.parse(mavenSettings)
return output."servers"."server"
}
def getCredentials() {
def entries = getMavenSettingsCredentials()
for (entry in entries) {
if (entry."id".text() == 'zomisnet') {
return [username: entry.username.text(), password: entry.password.text()]
}
}
return [username: 'invalid', password: 'invalid']
}
uploadArchives {
def creds = getCredentials()
if (!creds) {
return;
}
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: "ftp://www.zomis.net/public_html/maven") {
authentication(userName: creds["username"], password: creds["password"])
}
}
}
}
afterReleaseBuild.dependsOn uploadArchives