-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
224 lines (185 loc) · 7.3 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
buildscript {
repositories {
mavenLocal()
jcenter()
maven{url "http://dl.bintray.com/gridoptics/GOSS"}
maven{url "http://dl.bintray.com/gridoptics/goss"}
dependencies {
// Plugin for publishing to bintray for releases.
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
}
}
}
// Things that this project (root) and all subprojects have in common.
allprojects {
repositories {
mavenLocal()
jcenter()
}
apply plugin: 'com.jfrog.bintray' // used for bintray releases
apply plugin: 'maven-publish'
// Configure all subprojects with a src directory as an osgi (implies
// java) and groovy project.
configure(subprojects.findAll { new File(it.projectDir, 'src').directory }) {
apply plugin: 'osgi'
apply plugin: 'groovy'
}
group = 'pnnl.goss.tutorial'
version = currentVersion
// status == 'integration' or 'release'
//status = version.status
// ext.varname are public to the project level. With bintray this will
// automatically publish the artifacts. bintray gives us 24-hours to
// publish them. If not then they are deleted.
ext.publish = false
// Add the bintray closure for defining the project upload specifications
bintray {
// Test whether we are able to upload to bintray or not based upon whether
// the user has specified bintray_user and bintray_key in their
// gradle.properties file. This file is located in the $HOME/.gradle
// directory and is available for all gradle scripts.
if (project.hasProperty("bintray_user") && project.hasProperty("bintray_key")){
apiUrl = "https://api.bintray.com"
user = "${bintray_user}" // Defined in $HOME/.gradle/gradle.properties
key = "${bintray_key}" // Defined in $HOME/.gradle/gradle.properties
configurations = ['published', 'archives']
publish = project.publish
pkg {
repo = 'goss'
userOrg = 'gridoptics'
name = 'goss-tutorial'
desc = '''A small tutorial displaying a subset of capabilities
that the GOSS middleware platform promotes.'''
websiteUrl = 'https://github.com/GridOPTICS/GOSS-Tutorial'
issueTrackerUrl = 'https://github.com/GridOPTICS/GOSS-Tutorial/issues'
vcsUrl = 'https://github.com/GridOPTICS/GOSS-Tutorial.git'
licenses = ['BSD']
labels = ['goss', 'gridoptics', 'powergrid', 'fpgi', 'pnnl', 'tutorial']
attributes= ['plat': ['linux', 'windows']]
publicDownloadNumbers = false
}
}
}
}
subprojects {
apply plugin: 'maven'
if (project.plugins.hasPlugin('java')) {
sourceCompatibility = '1.7'
jar {
// Include source with the jar
from sourceSets.main.allSource
manifest {
instruction 'Bundle-Vendor', 'PNNL'
instruction 'Bundle-DocURL', 'https://github.com/GridOPTICS/GOSS'
[
compileJava,
compileTestJava,
javadoc
]*.options*.encoding = 'UTF-8'
}
}
configurations { published }
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
published sourceJar
published javadocJar
}
buildscript{
repositories {
maven{url "http://dl.bintray.com/gridoptics/GOSS"}
maven{url "http://dl.bintray.com/gridoptics/goss"}
mavenLocal()
jcenter()
}
dependencies{
classpath "pnnl.goss:goss-buildtools:${gossBuildToolsVersion}"
}
}
dependencies {
// Allow us to use groovy throughout the project.
compile "org.codehaus.groovy:groovy-all:$groovyVersion"
// Logging should be available to all projects
compile "org.slf4j:slf4j-api:${slf4jVersion}"
runtime "org.slf4j:slf4j-log4j12:${slf4jVersion}"
runtime "org.osgi:org.osgi.core:${osgiVersion}"
runtime "org.osgi:org.osgi.compendium:${osgiVersion}"
// For testing we are going to use these ubiquitous
testCompile "junit:junit:${junitVersion}"
testCompile "org.mockito:mockito-core:${mockitoVersion}"
testCompile "org.spockframework:spock-core:${spockVersion}"
}
// specify where source files can be located forthe projects.
sourceSets {
main {
// override the default locations, rather than adding additional ones
groovy { srcDirs = ['src/main/groovy', 'src/main/java'] }
// don't compile Java code twice (groovy will compile java files)
java { srcDirs = [] }
}
test {
groovy { srcDirs = ['src/test/java', 'src/test/groovy'] }
java { srcDirs = [] }
}
}
}
}
task build {
dependsOn subprojects.build
doLast {
copyConfigFiles
}
}
task install {
dependsOn build
dependsOn subprojects.install
dependsOn publishToMavenLocal
}
publishing {
publications {
featurePub(MavenPublication) {
artifact source: 'build/config/features.xml', classifier: 'features', extension: 'xml'
}
}
}
// Copy all config files to the output directory after replacing the properties that
// are available in the gradle.properties file. The project.version and project.name
// properties are also available for replacement. The property placeholder in the
// config iles should be wrapped in @, for example @activemqVersion@.
task copyConfigFiles(type: Copy) {
// we are going to attempt to build one big property replacement task so that we
// can use all the tokens in the feature file that are above in this file
// as well as the tokens in the goss.properties file.
File file = new File(System.getProperty("user.home")+"/.goss/goss.properties")
java.util.Properties javaProps = new java.util.Properties()
if (file.exists()){
javaProps.load(file.newDataInputStream())
}
else{
println "WARNING: goss.properties file not found."
//return
}
File cfgFolder = new File("$rootProject.projectDir/config")
File outFolder = new File("$rootProject.buildDir/config")
if (!outFolder.exists()){
outFolder.mkdirs()
}
cfgFolder.eachFile { cfg ->
String fileText = cfg.text
javaProps.each{ k,v ->
fileText = fileText.replaceAll('@'+k+'@', v.toString())
}
project.ext.properties.each {k, v ->
fileText = fileText.replaceAll('@'+k+'@', v.toString())
}
fileText = fileText.replace('@project.version@', project.version)
fileText = fileText.replace('@project.name@', project.name)
new File("$outFolder.absolutePath/$cfg.name").withWriter { out -> out.print fileText }
}
}