forked from psfblair/computation-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
202 lines (177 loc) · 6.53 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
/*
* Copyright 2014 Cyrus Innovation, LLC. Licensed under Apache license 2.0.
*/
apply plugin: 'scala'
version = projectVersion // See gradle.properties
group = artifactGroup
dependencies {
compile "org.scala-lang:scala-library:$scalaVersion"
}
allprojects {
apply plugin: 'idea' // Needed in here to handle multi-module IDEA projects
repositories {
mavenLocal()
mavenCentral()
maven {
name = 'sonatype-releases'
url = "https://oss.sonatype.org/content/repositories/releases"
}
}
tasks.withType(ScalaCompile) {
scalaCompileOptions.fork = true
scalaCompileOptions.useAnt = false
scalaCompileOptions.deprecation = true
scalaCompileOptions.unchecked = true
configure(scalaCompileOptions.forkOptions) {
memoryMaximumSize = '1g'
jvmArgs = ['-XX:MaxPermSize=256m']
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
}
subprojects {
apply plugin: 'scala'
apply plugin: 'signing'
apply plugin: 'maven-publish'
version = projectVersion
group = artifactGroup
publishToMavenLocal.dependsOn test
task test(overwrite: true, dependsOn: testClasses) << {
ant.taskdef(name: 'scalatest',
classname: 'org.scalatest.tools.ScalaTestAntTask',
classpath: sourceSets.test.runtimeClasspath.asPath
)
ant.scalatest(runpath: sourceSets.test.output.classesDir,
haltonfailure: 'true',
fork: 'true')
{reporter(type: 'stderr')}
}
def manifestAttributes = [
'Implementation-Version': version,
'Implementation-Vendor': artifactGroup
]
jar {
manifest {
attributes( manifestAttributes )
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allScala
classifier 'sources'
manifest {
attributes( manifestAttributes )
}
}
scaladoc.destinationDir = file("$projectDir/doc")
task scaladocJar(type: Jar, dependsOn: scaladoc) {
from scaladoc.destinationDir
classifier 'javadoc'
manifest {
attributes( manifestAttributes )
}
}
ext {
localStagingDir = "$buildDir/staging"
localStagingArtifactsDir = localStagingDir + "/" + group.replace('.', '/') + "/" + publishedArtifactId + "/" + version
pomFilePath = "$localStagingArtifactsDir/$publishedArtifactId-${version}.pom"
}
// These tasks are archive tasks that create an empty jar file to server as a bogus signature file
// so that the publish tasks don't fail because a signature doesn't exist yet. They will be overwritten
// when the jars are actually signed. [If the "publish" task is run rather than publishCodePublicationToSonatypeRepository
// then these will be executed after the signatures are uploaded, and overwrite them in the staging area.
// This seems harmless but isn't a very pretty side effect.
task initJarSignature(type: Jar, dependsOn: jar) {
destinationDir = file(localStagingArtifactsDir)
baseName = publishedArtifactId
appendix = ''
classifier = null
extension = 'jar.asc'
}
task initSourceJarSignature(type: Jar, dependsOn: sourceJar) {
destinationDir = file(localStagingArtifactsDir)
baseName = publishedArtifactId
appendix = ''
classifier = 'sources'
extension = 'jar.asc'
}
task initScaladocJarSignature(type: Jar, dependsOn: scaladocJar) {
destinationDir = file(localStagingArtifactsDir)
baseName = publishedArtifactId
appendix = ''
classifier = 'javadoc'
extension = 'jar.asc'
}
task initPomSignature(type: Jar) {
destinationDir = file(localStagingArtifactsDir)
baseName = publishedArtifactId
appendix = ''
classifier = null
extension = 'pom.asc'
}
//Signature info should go in user gradle.properties file ( ~/.gradle/gradle.properties)
task signArtifacts << {
file(project.ext.localStagingArtifactsDir).listFiles(new sun.misc.JarFilter()).each {
File f ->
println("Signing file ${f.getAbsolutePath()}")
signing.sign(f)
}
println("Signing file ${pomFilePath}")
signing.sign(file(pomFilePath))
}
gradle.taskGraph.whenReady {taskGraph ->
gradle.taskGraph.beforeTask { task ->
if (task == tasks.publishCodePublicationToSonatypeRepository) {
publishCodePublicationToInternalRepository.execute()
signArtifacts.execute()
publishJarSignaturesPublicationToSonatypeRepository.execute()
publishPomSignaturePublicationToSonatypeRepository.execute()
}
}
}
// You need to execute publishToMavenLocal before using publish to push to Sonatype
publishing {
//Sonatype username and password should go in user gradle.properties file ( ~/.gradle/gradle.properties)
repositories {
maven {
name 'sonatype'
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username = sonatypeUsername
password = sonatypePassword
}
// For testing
// url "$buildDir/repo"
}
maven {
name 'internal'
url "${project.ext.localStagingDir}"
}
}
publications {
//When the publish task is called, the publications are published in alphabetical order (and
//the target repositories are also pushed to in alphabetical order). So naming is unfortunately
//important.
code(MavenPublication) {
from components.java
artifact scaladocJar
artifact sourceJar
}
// Gradle disallows having multiple publish artifacts with a null classifier; the classifier is
// automatically inserted between the artifact name and the extension. As a result, we have to
// deal with the jars and the pom as separate publications.
jarSignatures(MavenPublication) {
artifact initJarSignature
artifact initSourceJarSignature
artifact initScaladocJarSignature
}
pomSignature(MavenPublication) {
artifact initPomSignature {
classifier = null
extension = 'pom.asc'
}
}
}
}
}