|
| 1 | +apply from: 'build.shared' |
| 2 | +apply plugin: 'maven-publish' |
| 3 | +apply plugin: 'signing' |
| 4 | + |
| 5 | +sourceCompatibility = 1.8 |
| 6 | +targetCompatibility = 1.8 |
| 7 | + |
| 8 | +test { |
| 9 | + maxParallelForks = Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 2)) |
| 10 | +} |
| 11 | + |
| 12 | +def findJVM() { |
| 13 | + String[] java8Paths = new String[5] |
| 14 | + java8Paths[0] = "/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/" |
| 15 | + java8Paths[1] = "/usr/lib/jvm/java-8-openjdk/jre/lib/" |
| 16 | + java8Paths[2] = "/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/" |
| 17 | + java8Paths[3] = "/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/" |
| 18 | + java8Paths[4] = "/usr/lib/jvm/java-8-sun/jre/lib/" |
| 19 | + for (String path : java8Paths) { |
| 20 | + if (new java.io.File(path).exists()) { |
| 21 | + return path |
| 22 | + } |
| 23 | + } |
| 24 | + return null |
| 25 | +} |
| 26 | + |
| 27 | +compileJava { |
| 28 | + def jvmPath = findJVM() |
| 29 | + if (jvmPath == null) { |
| 30 | + println 'Unable to find java 8 rt.jar, will cause failure so exiting now' |
| 31 | + println '' |
| 32 | + System.exit(1) |
| 33 | + } |
| 34 | + println 'Using java 8: ' + jvmPath |
| 35 | + options.bootstrapClasspath = fileTree(include: ['*.jar'], dir: jvmPath) |
| 36 | +} |
| 37 | + |
| 38 | +compileTestJava { |
| 39 | + options.compilerArgs << "-Xlint:all" << "-Xlint:-deprecation" << "-Werror" |
| 40 | + |
| 41 | + options.bootstrapClasspath = fileTree(include: ['*.jar'], dir: findJVM()) |
| 42 | +} |
| 43 | + |
| 44 | +signing { |
| 45 | + sign configurations.archives |
| 46 | + if (! version.contains('SNAPSHOT')) { |
| 47 | + sign publishing.publications |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +publishing { |
| 52 | + publications { |
| 53 | + mavenJava(MavenPublication) { |
| 54 | + pom { |
| 55 | + name = 'Threadly' |
| 56 | + description = 'A library of tools to assist with safe concurrent java development.' |
| 57 | + url = 'http://threadly.org/' |
| 58 | + |
| 59 | + scm { |
| 60 | + url = 'scm: [email protected]:threadly/threadly.git' |
| 61 | + connection = 'scm: [email protected]:threadly/threadly.git' |
| 62 | + developerConnection = 'scm: [email protected]:threadly/threadly.git' |
| 63 | + } |
| 64 | + |
| 65 | + issueManagement { |
| 66 | + system = 'GitHub' |
| 67 | + url = 'https://github.com/threadly/threadly/issues' |
| 68 | + } |
| 69 | + |
| 70 | + licenses { |
| 71 | + license { |
| 72 | + name = 'Mozilla Public License Version 2.0' |
| 73 | + url = 'https://www.mozilla.org/MPL/2.0/' |
| 74 | + distribution = 'repo' |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + developers { |
| 79 | + developer { |
| 80 | + id = 'jent' |
| 81 | + name = 'Mike Jensen' |
| 82 | + |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + from components.java |
| 88 | + |
| 89 | + artifact(sourcesJar) { |
| 90 | + classifier = 'sources' |
| 91 | + } |
| 92 | + artifact(javadocJar) { |
| 93 | + classifier = 'javadoc' |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + repositories { |
| 98 | + maven { |
| 99 | + def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" |
| 100 | + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" |
| 101 | + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl |
| 102 | + credentials { |
| 103 | + username sonatypeUsername |
| 104 | + password sonatypePassword |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +model { |
| 111 | + tasks.generatePomFileForMavenJavaPublication { |
| 112 | + destination = file("$buildDir/generated-pom.xml") |
| 113 | + } |
| 114 | + tasks.publishMavenJavaPublicationToMavenLocal { |
| 115 | + dependsOn project.tasks.signArchives |
| 116 | + } |
| 117 | + tasks.publishMavenJavaPublicationToMavenRepository { |
| 118 | + dependsOn project.tasks.signArchives |
| 119 | + } |
| 120 | +} |
0 commit comments