forked from kutrumbo/java-ddp-client
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbuild.gradle
167 lines (145 loc) · 4.92 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
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'signing'
apply plugin: 'maven'
group = 'com.keysolutions'
version = '1.0.0.7'
// compile for JDK 1.5 for maximum backwards compatibility
sourceCompatibility = 1.5
targetCompatibility = 1.5
// get rid of bootclasspath warning by setting it
def env = System.getenv()
def bootClasspathStr = env['JAVA_HOME'] + "/jre/lib/rt.jar"
println env['JAVA_HOME']+'/jre/lib/rt.jar'
project.tasks.withType(AbstractCompile, { AbstractCompile ac ->
ac.options.bootClasspath = bootClasspathStr // options is always there but not defined on AbstractCompile so going to hit it anyway
})
// set default for sonatype variables so it can be built on checkout
if (!project.hasProperty("sonatypeUsername")) {
ext.sonatypeUsername = "username"
}
if (!project.hasProperty("sonatypePassword")) {
ext.sonatypePassword = "password"
}
jar {
manifest {
attributes 'Implementation-Title': 'Java DDP Client Library', 'Implementation-Version': version
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
repositories {
mavenCentral()
maven {
url 'http://clojars.org/repo'
}
}
dependencies {
compile "org.apache.commons:commons-collections4:[4.0,5.0)"
testCompile "junit:junit:[4,5)"
compile "org.java-websocket:Java-WebSocket:1.3.4"
compile "com.google.code.gson:gson:[2.3,3.0)"
compile "org.slf4j:slf4j-api:[1.7,1.8)"
compile "org.slf4j:slf4j-simple:[1.7,1.8)"
compile "com.nimbusds:srp6a:[1.5,1.6)"
}
test {
systemProperties 'property': 'value'
}
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project {
name 'JavaDDPClient'
packaging 'jar'
description 'JavaDDPClient is a Java library for the Meteor.js framework DDP websocket protocol'
url 'https://github.com/kenyee/java-ddp-client'
scm {
url 'scm:[email protected]:kenyee/java-ddp-client.git'
connection 'scm:[email protected]:kenyee/java-ddp-client.git'
developerConnection 'scm:[email protected]:kenyee/java-ddp-client.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'kenyee'
name 'Ken Yee'
}
}
}
}
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
signing {
sign configurations.archives
}
// use this for testing pom.xml generation
task writeNewPom doLast {
pom {
project {
inceptionYear '2013'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
/* converts Gradle dynamic dependency syntax
whenConfigured { generatedPom ->
generatedPom.dependencies.each { mavenDep ->
if (isDynamic(mavenDep)) {
mavenDep.version = '[' + mavenDep.version[0..-2] + ',)'
}
}
}
*/
}.writeTo("$buildDir/newpom.xml")
}
/**
* Locks a Maven dependency into a specific version.
* @param dep the dependency
*/
void lockDependency(def dep) {
if (isDynamic(dep)) {
project.logger.info("Lockin $dep into a specific revision")
Configuration conf = project.configurations.findByName(dep.scope)
if (conf == null) {
throw new Exception("Unable to lock $dep due to missing configuration, aborting as dependency tree will be unstable")
} else {
def matches = conf.resolvedConfiguration.resolvedArtifacts.findAll {
it.moduleVersion.id.group.equals(dep.groupId) && it.moduleVersion.id.name.equals(dep.artifactId) && (it.classifier == null || (it.classifier != null && it.classifier.equals(dep.classifier)))
}
if (matches.size() > 1)
throw new Exception("Unable to lock $dep due to multiple resolved dependencies, aborting as dependency tree will be unstable")
else
matches.each { dep.version = it.moduleVersion.id.version }
}
}
}
/*
* Checks for whether a dependency is dynamic
*/
boolean isDynamic(def dep) {
return dep.version.any { it == '[' || it == ']' || it == '(' || it == ')' || it == '+' }
}