|
| 1 | +import org.apache.tools.ant.filters.ReplaceTokens |
| 2 | + |
| 3 | +buildscript { |
| 4 | + repositories { |
| 5 | + mavenCentral() |
| 6 | + } |
| 7 | + dependencies { |
| 8 | + classpath 'org.ajoberstar:gradle-git:1.1.0' |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +plugins { |
| 13 | + id 'java-library' |
| 14 | + id 'maven-publish' |
| 15 | + id "signing" |
| 16 | + id "org.ajoberstar.github-pages" version "1.7.2" |
| 17 | +} |
| 18 | + |
| 19 | +def getProperty = { property -> |
| 20 | + if (!project.hasProperty(property)) { |
| 21 | + throw new GradleException("${property} property must be set") |
| 22 | + } |
| 23 | + return project.property(property) |
| 24 | +} |
| 25 | + |
| 26 | +repositories { |
| 27 | + mavenCentral() |
| 28 | +} |
| 29 | + |
| 30 | +group = "com.pusher" |
| 31 | +version = "1.3.3" |
| 32 | +description = "Pusher HTTP Client" |
| 33 | +sourceCompatibility = "1.8" |
| 34 | +targetCompatibility = "1.8" |
| 35 | + |
| 36 | +ext.sharedManifest = manifest { |
| 37 | + attributes( |
| 38 | + 'Created-By': 'Pusher', |
| 39 | + 'Implementation-Vendor': 'Pusher', |
| 40 | + 'Implementation-Title': 'Pusher HTTP Java', |
| 41 | + 'Implementation-Version': version |
| 42 | + ) |
| 43 | +} |
| 44 | + |
| 45 | +dependencies { |
| 46 | + implementation 'org.apache.httpcomponents:httpclient:4.5.13' |
| 47 | + implementation 'org.asynchttpclient:async-http-client:2.12.3' |
| 48 | + implementation 'com.google.code.gson:gson:2.8.9' |
| 49 | + testImplementation 'org.apache.httpcomponents:httpclient:4.5.13' |
| 50 | + testImplementation 'org.hamcrest:hamcrest-all:1.3' |
| 51 | + testImplementation 'org.jmock:jmock-junit5:2.12.0' |
| 52 | + testImplementation 'org.jmock:jmock-imposters:2.12.0' |
| 53 | + testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' |
| 54 | +} |
| 55 | + |
| 56 | +processResources { |
| 57 | + filter(ReplaceTokens, tokens: [ |
| 58 | + version: project.version |
| 59 | + ]) |
| 60 | +} |
| 61 | + |
| 62 | +javadoc { |
| 63 | + title "Pusher HTTP Java" |
| 64 | + options.linkSource = true |
| 65 | +} |
| 66 | + |
| 67 | +jar { |
| 68 | + duplicatesStrategy = DuplicatesStrategy.EXCLUDE |
| 69 | + manifest = project.manifest { |
| 70 | + from sharedManifest |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +task sourcesJar(type: Jar, dependsOn: classes) { |
| 75 | + archiveClassifier.set('sources') |
| 76 | + from sourceSets.main.allSource |
| 77 | +} |
| 78 | +assemble.dependsOn sourcesJar |
| 79 | + |
| 80 | + |
| 81 | +task javadocJar(type: Jar, dependsOn: javadoc) { |
| 82 | + archiveClassifier.set('javadoc') |
| 83 | + from javadoc.destinationDir |
| 84 | +} |
| 85 | +assemble.dependsOn javadocJar |
| 86 | + |
| 87 | +artifacts { |
| 88 | + archives jar, sourcesJar, javadocJar |
| 89 | +} |
| 90 | + |
| 91 | +java { |
| 92 | + withSourcesJar() |
| 93 | + withJavadocJar() |
| 94 | +} |
| 95 | + |
| 96 | +githubPages { |
| 97 | + repoUri = 'https://github.com/pusher/pusher-http-java.git' |
| 98 | + pages { |
| 99 | + from javadoc.outputs.files |
| 100 | + } |
| 101 | + commitMessage = "JavaDoc gh-pages for ${version}" |
| 102 | + credentials { |
| 103 | + username = { getProperty("github.username") } |
| 104 | + password = { getProperty("github.password") } |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +publishing { |
| 109 | + publications { |
| 110 | + mavenJava(MavenPublication) { |
| 111 | + artifactId = 'pusher-http-java' |
| 112 | + |
| 113 | + from components.java |
| 114 | + pom { |
| 115 | + name = 'Pusher HTTP Client' |
| 116 | + packaging = 'jar' |
| 117 | + artifactId = 'pusher-java-client' |
| 118 | + description = "This is a Java library for interacting with Pusher.com's HTTP API." |
| 119 | + url = 'http://github.com/pusher/pusher-http-java' |
| 120 | + scm { |
| 121 | + connection = 'scm:git:git@github.com:pusher/pusher-http-java' |
| 122 | + developerConnection = 'scm:git:git@github.com:pusher/pusher-http-java' |
| 123 | + url = 'http://github.com/pusher/pusher-http-java' |
| 124 | + } |
| 125 | + licenses { |
| 126 | + license { |
| 127 | + name = 'MIT' |
| 128 | + url = 'https://raw.github.com/pusher/pusher-http-java/master/LICENCE.txt' |
| 129 | + distribution = 'https://raw.github.com/pusher/pusher-http-java/mvn-repo/' |
| 130 | + } |
| 131 | + } |
| 132 | + organization { |
| 133 | + name = 'Pusher' |
| 134 | + url = 'http://pusher.com' |
| 135 | + } |
| 136 | + issueManagement { |
| 137 | + system = 'GitHub' |
| 138 | + url = 'https://github.com/pusher/pusher-http-java/issues' |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + repositories { |
| 144 | + maven { |
| 145 | + def releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" |
| 146 | + def snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/" |
| 147 | + url = version.endsWith("SNAPSHOT") ? snapshotRepositoryUrl : releaseRepositoryUrl |
| 148 | + credentials { |
| 149 | + username = findProperty("maven.username") ?: "" |
| 150 | + password = findProperty("maven.password") ?: "" |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | +} |
| 155 | + |
| 156 | +signing { |
| 157 | + sign publishing.publications.mavenJava |
| 158 | +} |
| 159 | + |
| 160 | +test { |
| 161 | + useJUnitPlatform() |
| 162 | + |
| 163 | + testLogging { |
| 164 | + showStandardStreams = true |
| 165 | + } |
| 166 | +} |
0 commit comments