-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
158 lines (132 loc) · 5.78 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
149
150
151
152
153
154
155
156
157
158
plugins {
id 'java'
id 'maven'
id 'com.github.hierynomus.license' version '0.14.0'
}
group 'net.netzgut.integral'
version '0.0.3-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
jcenter()
mavenLocal()
}
project.ext.versions = [
slf4j: '1.7.25',
tapestry: '5.4.3',
quartz: '2.2.3',
// provided
servlet: '3.1.0',
// test
log4j: '1.2.17',
hsqldb: '2.3.4',
testng: '6.12'
]
project.ext.moduleClasses = 'net.netzgut.integral.quartz.QuartzModule'
dependencies {
compile "org.slf4j:slf4j-api:${versions.slf4j}"
compile "org.apache.tapestry:tapestry-ioc:${versions.tapestry}"
compile "org.quartz-scheduler:quartz:${versions.quartz}"
compileOnly "javax.servlet:javax.servlet-api:${versions.servlet}"
testCompile "org.slf4j:slf4j-log4j12:${versions.slf4j}"
testCompile group: 'org.hsqldb', name: 'hsqldb', version: versions.hsqldb
testCompile "org.testng:testng:${versions.testng}"
}
jar {
manifest { attributes 'Tapestry-Module-Classes': moduleClasses }
}
task wrapper(type: Wrapper) { gradleVersion = '4.6' }
task pom {
doLast {
pom {
packaging = 'jar'
project {
inceptionYear '2017'
name rootProject.name
description 'A Quartz Scheduler integration for tapestry 5.4'
url 'https://github.com/netzgut/integral-quartz'
properties { 'project.build.sourceEncoding' 'UTF-8' }
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url 'https://github.com/netzgut/integral-quartz'
connection 'scm:git:git://github.com/netzgut/integral-quartz.git'
developerConnection 'scm:git:git@github.com:netzgut/integral-quartz.git'
}
}
}.withXml { xmlProvider ->
// We need to add the compileOnly dependencies manually, maven-plugin isn't supporting it.
project.configurations.compileOnly.allDependencies.each { dep ->
asNode().dependencies[0].appendNode('dependency').with {
it.appendNode('groupId', dep.group)
it.appendNode('artifactId', dep.name)
it.appendNode('version', dep.version)
it.appendNode('scope', 'provided')
}
}
// Sort the dependencies so the order wont change with every invocation
def dependenciesNodeList = node.get('dependencies')
if (dependenciesNodeList) {
def dependenciesNode = dependenciesNodeList.get(0)
def dependencyNodeList = dependenciesNode.get('dependency')
def sorted = dependencyNodeList.sort { a, b ->
def r = a.get('groupId').text().trim().compareTo(b.get('groupId').text().trim())
if (r != 0) return r
return a.get('artifactId').text().trim().compareTo(b.get('artifactId').text().trim())
}
dependenciesNode.children().removeAll(dependenciesNode.children())
sorted.each { dependenciesNode.append(it) }
}
// Add plugins
def plugins = xmlProvider.asNode().appendNode('build').appendNode('plugins')
def mavenCompilerPlugin = plugins.appendNode('plugin')
mavenCompilerPlugin.appendNode('artifactId').value = 'maven-compiler-plugin'
mavenCompilerPlugin.appendNode('version').value = '3.5.1'
def mavenCompilerPluginConfiguration = mavenCompilerPlugin.appendNode('configuration')
mavenCompilerPluginConfiguration.appendNode('source').value = sourceCompatibility
mavenCompilerPluginConfiguration.appendNode('target').value = targetCompatibility
def mavenSurefirePlugin = plugins.appendNode('plugin')
mavenSurefirePlugin.appendNode('artifactId').value = 'maven-surfire-plugin'
mavenSurefirePlugin.appendNode('version').value = '2.19.1'
mavenSurefirePlugin.appendNode('configuration')
def mavenJarPlugin = plugins.appendNode('plugin')
mavenJarPlugin.appendNode('artifactId').value = 'maven-jar-plugin'
def mavenJarPluginConfigurationManifest = mavenJarPlugin.appendNode('configuration').appendNode('archive').appendNode('manifestEntries')
mavenJarPluginConfigurationManifest.appendNode('Tapestry-Module-Classes').value = moduleClasses
}.writeTo('pom.xml')
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
test {
useTestNG()
}
license {
header rootProject.file('src/main/resources/META-INF/LICENSE.txt')
strictCheck true
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
uploadArchives {
// We need to set the variables if not present
ext.snapshot_repository = project.hasProperty('snapshot-repository') ? project.property('snapshot-repository') : ''
ext.snapshot_repository_username = project.hasProperty('snapshot-repository-username') ? project.property('snapshot-repository-username') : ''
ext.snapshot_repository_password = project.hasProperty('snapshot-repository-password') ? project.property('snapshot-repository-password') : ''
repositories {
mavenDeployer {
snapshotRepository(url: snapshot_repository) {
authentication(userName: snapshot_repository_username, password: snapshot_repository_password)
}
}
}
}