forked from airlift/airline
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
118 lines (100 loc) · 3.25 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
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: "maven"
tasks.create(name: 'wrapper_task' ,type: Wrapper) {
gradleVersion = '6.0.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-6.0.1-all.zip"
}
allprojects {
group = "com.complexible.airline"
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
version = "0.8.3"
repositories {
mavenCentral()
}
}
ext {
projectDescription = "Airline is a Java annotation-based framework for parsing Git like command line structures."
projectUrl = "https://github.com/clarkparsia/airline"
}
dependencies {
compile 'javax.inject:javax.inject:1'
compile "com.google.guava:guava:27.0-jre"
compile 'com.google.code.findbugs:jsr305:3.0.0'
testCompile 'org.testng:testng:6.0.1'
}
if (project.hasProperty('artifactoryUrl')
&& project.hasProperty('artifactoryUsername')
&& project.hasProperty('artifactoryPassword')) {
repoUpload(taskName: 'uploadArtifactory',
url: artifactoryUrl,
username: artifactoryUsername,
password: artifactoryPassword)
}
if (project.hasProperty('publicRepository')) {
repoUpload(taskName: 'uploadGithub',
url: "file://localhost/$publicRepository")
}
def repoUpload(Map<String, String> options) {
def taskName = options.taskName
def repoUrl = options.url
def username = null
def passwd = null
def auth = options.containsKey("username") && options.containsKey("password")
if (auth) {
username = options.username
passwd = options.password
}
task(taskName, type: Upload) {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: repoUrl) {
if (auth) {
authentication(userName: username, password: passwd)
}
}
pom.project {
name = archivesBaseName
packaging = 'jar'
description projectDescription
url projectUrl
}
//mess with the generated pom to remove test dependencies from published artifacts
pom.withXml { XmlProvider xmlProvider ->
def xml = xmlProvider.asString()
def pomXml = new XmlParser().parse(new ByteArrayInputStream(xml.toString().bytes))
pomXml.dependencies.dependency.each { dep ->
if (dep.scope.text() != 'compile') {
def parent = dep.parent()
parent.remove(dep)
}
}
// add exclusion nodes (only for compile conf) since the maven plugin
// doesn't handle them as of gradle 1.9
project.configurations.compile.allDependencies.findAll {
it instanceof ModuleDependency && !it.excludeRules.isEmpty()
}.each { ModuleDependency dep ->
def xmlDep = pomXml.dependencies.dependency.find {
it.groupId[0].text() == dep.group && it.artifactId[0].text() == dep.name
}
def xmlExclusions = xmlDep.exclusions
if (!xmlExclusions) xmlExclusions = xmlDep.appendNode('exclusions')
dep.excludeRules.each { ExcludeRule rule ->
def xmlExclusion = xmlExclusions.appendNode('exclusion')
xmlExclusion.appendNode('groupId', rule.group)
xmlExclusion.appendNode('artifactId', rule.module ?: '*')
}
}
def newXml = new StringWriter()
def printer = new XmlNodePrinter(new PrintWriter(newXml))
printer.preserveWhitespace = true
printer.print(pomXml)
xml.setLength(0)
xml.append(newXml.toString())
}
}
}
}
}