|
| 1 | +subprojects { |
| 2 | + apply plugin: 'java' |
| 3 | + apply plugin: 'checkstyle' |
| 4 | + apply plugin: 'jacoco' |
| 5 | + apply plugin: 'maven' |
| 6 | + apply plugin: 'signing' |
| 7 | + |
| 8 | + repositories { |
| 9 | + mavenCentral() |
| 10 | + maven { |
| 11 | + url 'https://oss.sonatype.org/content/repositories/snapshots/' |
| 12 | + } |
| 13 | + } |
| 14 | + |
| 15 | + sourceCompatibility = 1.8 |
| 16 | + targetCompatibility = 1.8 |
| 17 | + |
| 18 | + compileJava { |
| 19 | + String[] java8Paths = new String[9] |
| 20 | + java8Paths[0] = "/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/" |
| 21 | + java8Paths[1] = "/usr/lib/jvm/java-8-openjdk/jre/lib/" |
| 22 | + java8Paths[2] = "/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/" |
| 23 | + java8Paths[3] = "/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/" |
| 24 | + java8Paths[4] = "/usr/lib/jvm/java-8-sun/jre/lib/" |
| 25 | + java8Paths[5] = "/usr/lib/jvm/jdk1.8.0_122/jre/lib/" |
| 26 | + java8Paths[6] = "/usr/lib/jvm/jdk1.8.0_65/jre/lib/" |
| 27 | + java8Paths[7] = "/usr/lib/jvm/jdk1.8.0_45/jre/lib/" |
| 28 | + java8Paths[8] = "/usr/lib/jvm/jdk1.8.0_20/jre/lib/" |
| 29 | + for (String path : java8Paths) { |
| 30 | + if (new java.io.File(path).exists()) { |
| 31 | + println 'Using java 8: ' + path |
| 32 | + options.bootstrapClasspath = fileTree(include: ['*.jar'], dir: path) |
| 33 | + break |
| 34 | + } |
| 35 | + } |
| 36 | + if (options.bootstrapClasspath == null) { |
| 37 | + println 'Unable to find java 8 rt.jar, will cause failure so exiting now' |
| 38 | + println '' |
| 39 | + System.exit(1) |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + compileTestJava { |
| 44 | + options.compilerArgs << "-Xlint:all" << "-Xlint:-deprecation" << "-Werror" |
| 45 | + |
| 46 | + String[] java8Paths = new String[9] |
| 47 | + java8Paths[0] = "/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/" |
| 48 | + java8Paths[1] = "/usr/lib/jvm/java-8-openjdk/jre/lib/" |
| 49 | + java8Paths[2] = "/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/" |
| 50 | + java8Paths[3] = "/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/" |
| 51 | + java8Paths[4] = "/usr/lib/jvm/java-8-sun/jre/lib/" |
| 52 | + java8Paths[5] = "/usr/lib/jvm/jdk1.8.0_122/jre/lib/" |
| 53 | + java8Paths[6] = "/usr/lib/jvm/jdk1.8.0_65/jre/lib/" |
| 54 | + java8Paths[7] = "/usr/lib/jvm/jdk1.8.0_45/jre/lib/" |
| 55 | + java8Paths[8] = "/usr/lib/jvm/jdk1.8.0_20/jre/lib/" |
| 56 | + for (String path : java8Paths) { |
| 57 | + if (new java.io.File(path).exists()) { |
| 58 | + options.bootstrapClasspath = fileTree(include: ['*.jar'], dir: path) |
| 59 | + break |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + signing { |
| 65 | + sign configurations.archives |
| 66 | + } |
| 67 | + |
| 68 | + uploadArchives { |
| 69 | + repositories { |
| 70 | + mavenDeployer { |
| 71 | + beforeDeployment { |
| 72 | + MavenDeployment deployment -> signing.signPom(deployment) |
| 73 | + } |
| 74 | + |
| 75 | + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { |
| 76 | + authentication(userName: sonatypeUsername, password: sonatypePassword) |
| 77 | + } |
| 78 | + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") { |
| 79 | + authentication(userName: sonatypeUsername, password: sonatypePassword) |
| 80 | + } |
| 81 | + |
| 82 | + pom.project { |
| 83 | + name 'litesockets-http' |
| 84 | + packaging 'jar' |
| 85 | + description 'Libraries to help parse and use HTTP protocol' |
| 86 | + url 'http://threadly.org/' |
| 87 | + |
| 88 | + scm { |
| 89 | + url 'scm: [email protected]:threadly/litesockets-http.git' |
| 90 | + connection 'scm: [email protected]:threadly/litesockets-http.git' |
| 91 | + developerConnection 'scm: [email protected]:threadly/litesockets-http.git' |
| 92 | + } |
| 93 | + |
| 94 | + licenses { |
| 95 | + license { |
| 96 | + name 'Mozilla Public License Version 2.0' |
| 97 | + url 'https://www.mozilla.org/MPL/2.0/' |
| 98 | + distribution 'repo' |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + developers { |
| 103 | + developer { |
| 104 | + id 'jent' |
| 105 | + name 'Mike Jensen' |
| 106 | + |
| 107 | + } |
| 108 | + developer { |
| 109 | + id 'lwahlmeier' |
| 110 | + name 'Luke Wahlmeier' |
| 111 | + |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + compileJava { |
| 120 | + options.compilerArgs << "-Xlint:all" << "-Werror" |
| 121 | + } |
| 122 | + |
| 123 | + compileTestJava { |
| 124 | + options.compilerArgs << "-Xlint:all" << "-Werror" |
| 125 | + } |
| 126 | + |
| 127 | + plugins.withType(JavaPlugin) { |
| 128 | + checkstyle.sourceSets = [sourceSets.main] |
| 129 | + } |
| 130 | + |
| 131 | + test { |
| 132 | + maxParallelForks = Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 4)) |
| 133 | + jacoco { |
| 134 | + excludes = ['**/package-info**','**/*Test'] |
| 135 | + destinationFile = file("$buildDir/reports/jacoco/test.exec") |
| 136 | + } |
| 137 | + getReports().getJunitXml().setDestination(file("$buildDir/reports/tests/xml")) |
| 138 | + getReports().getHtml().setDestination(file("$buildDir/reports/tests/html")) |
| 139 | + setBinResultsDir(file("$buildDir/reports/tests/bin")) |
| 140 | + } |
| 141 | + |
| 142 | + build.dependsOn jacocoTestReport |
| 143 | + |
| 144 | + jacocoTestReport { |
| 145 | + doFirst { |
| 146 | + classDirectories = fileTree(dir: 'build/classes/java/main', include: 'org/threadly/**') |
| 147 | + sourceDirectories = fileTree(dir: 'src/main/java', include: 'org/threadly/**') |
| 148 | + } |
| 149 | + reports { |
| 150 | + csv.enabled = false |
| 151 | + xml.enabled = true |
| 152 | + xml.destination = file("$buildDir/reports/jacoco/jacoco.xml") |
| 153 | + html.enabled = true |
| 154 | + html.destination = file("$buildDir/reports/jacoco/html") |
| 155 | + } |
| 156 | + doLast { |
| 157 | + println "Test results available at:" |
| 158 | + println "html - $buildDir/reports/tests/html/index.html" |
| 159 | + println "Test coverage reports available at:" |
| 160 | + println "html - $buildDir/reports/jacoco/html/index.html" |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + jar { |
| 165 | + manifest { |
| 166 | + attributes 'Implementation-Title': 'litesockets-http', 'Implementation-Version': version |
| 167 | + } |
| 168 | + } |
| 169 | + |
| 170 | + javadoc { |
| 171 | + source = sourceSets.main.allJava |
| 172 | + options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PUBLIC |
| 173 | + } |
| 174 | + |
| 175 | + task javadocJar(type: Jar, dependsOn: javadoc) { |
| 176 | + classifier = 'javadoc' |
| 177 | + from 'build/docs/javadoc' |
| 178 | + } |
| 179 | + |
| 180 | + task sourcesJar(type: Jar) { |
| 181 | + from sourceSets.main.allSource |
| 182 | + classifier = 'sources' |
| 183 | + } |
| 184 | + |
| 185 | + build.dependsOn("copyLibs"); |
| 186 | + |
| 187 | + task copyLibs(type: Copy) { |
| 188 | + into "$buildDir/dependencies/" |
| 189 | + from configurations.testRuntime |
| 190 | + } |
| 191 | + |
| 192 | + artifacts { |
| 193 | + archives jar |
| 194 | + archives javadocJar |
| 195 | + archives sourcesJar |
| 196 | + } |
| 197 | +} |
| 198 | + |
| 199 | + |
| 200 | +project(':protocol') { |
| 201 | + archivesBaseName = 'litesockets-http-protocol' |
| 202 | + |
| 203 | + dependencies { |
| 204 | + compile ( |
| 205 | + "org.threadly:threadly:$threadlyVersion", |
| 206 | + "org.threadly:litesockets:$litesocketsVersion" |
| 207 | + ) |
| 208 | + |
| 209 | + testCompile ( |
| 210 | + "junit:junit:$junitVersion", |
| 211 | + ) |
| 212 | + } |
| 213 | +} |
| 214 | + |
| 215 | + |
| 216 | +project(':client') { |
| 217 | + archivesBaseName = 'litesockets-http-client' |
| 218 | + |
| 219 | + dependencies { |
| 220 | + compile ( |
| 221 | + project(":protocol"), |
| 222 | + "org.threadly:threadly:$threadlyVersion", |
| 223 | + "org.threadly:litesockets:$litesocketsVersion" |
| 224 | + ) |
| 225 | + testCompile ( |
| 226 | + "junit:junit:$junitVersion", |
| 227 | + ) |
| 228 | + } |
| 229 | +} |
| 230 | + |
| 231 | +project(':server') { |
| 232 | + archivesBaseName = 'litesockets-http-server' |
| 233 | + |
| 234 | + dependencies { |
| 235 | + compile ( |
| 236 | + project(":protocol"), |
| 237 | + "org.threadly:threadly:$threadlyVersion", |
| 238 | + "org.threadly:litesockets:$litesocketsVersion" |
| 239 | + ) |
| 240 | + testCompile ( |
| 241 | + "junit:junit:$junitVersion", |
| 242 | + ) |
| 243 | + } |
| 244 | +} |
| 245 | + |
0 commit comments