Skip to content

Commit 526c367

Browse files
committed
Improve build script
* Split release logic into release.gradle * Update Gradle wrapper from 3.0 to 4.10.2 * Drop the deprecated JUnit Platform Gradle plugin * Apply application plugin to run the CLI from Gradle
1 parent d6e7ccc commit 526c367

File tree

4 files changed

+119
-123
lines changed

4 files changed

+119
-123
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ To give credit where credit is due, the PushService is mostly a Java port of mar
176176

177177
- [Voluntary Application Server Identification for Web Push](https://tools.ietf.org/html/draft-ietf-webpush-vapid-01)
178178
- [Web Push Book](https://web-push-book.gauntface.com/)
179+
- [Simple Push Demo](https://gauntface.github.io/simple-push-demo/)
179180
- [Web Push: Data Encryption Test Page](https://jrconlin.github.io/WebPushDataTestPage/)
180181
- [Push Companion](https://web-push-codelab.appspot.com/)
181182

build.gradle

+61-121
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,65 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
4-
}
5-
dependencies {
6-
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4'
7-
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.8.0'
8-
}
1+
plugins {
2+
id 'application'
3+
id 'com.github.johnrengelman.shadow' version '4.0.2'
4+
5+
// Used by release.gradle
6+
id 'maven'
7+
id 'signing'
8+
id 'io.codearte.nexus-staging' version '0.12.0'
99
}
1010

11-
plugins {
12-
id 'com.github.johnrengelman.shadow' version '2.0.0'
11+
if (hasProperty('release')) {
12+
apply from: 'release.gradle'
1313
}
1414

15+
apply plugin: 'application'
16+
apply plugin: 'com.github.johnrengelman.shadow'
17+
1518
group 'nl.martijndwars'
1619
version '3.1.1'
1720

18-
apply plugin: 'java'
19-
apply plugin: 'maven'
20-
apply plugin: 'signing'
21-
apply plugin: 'org.junit.platform.gradle.plugin'
22-
apply plugin: 'io.codearte.nexus-staging'
21+
repositories {
22+
mavenLocal()
23+
mavenCentral()
24+
}
25+
26+
dependencies {
27+
// For CLI
28+
compile group: 'com.beust', name: 'jcommander', version: '1.72'
29+
30+
// For parsing JSON
31+
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
32+
33+
// For making async HTTP requests
34+
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.3'
35+
36+
// For cryptographic operations
37+
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.54'
2338

24-
task wrapper(type: Wrapper) {
25-
gradleVersion = '3.0'
39+
// For creating and signing JWT
40+
compile group: 'org.bitbucket.b_c', name: 'jose4j', version: '0.5.2'
41+
42+
// For making HTTP requests
43+
testCompile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.2'
44+
45+
// For testing, obviously
46+
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.3.1'
47+
48+
// For running JUnit tests
49+
testRuntime group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.3.1'
50+
51+
// For turning InputStream to String
52+
testCompile group: 'commons-io', name: 'commons-io', version: '2.5'
53+
54+
// For reading the demo vapid keypair from a pem file
55+
testCompile group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.55'
56+
57+
// For verifying Base64Encoder results in unit tests
58+
testCompile group: 'com.google.guava', name: 'guava', version: '19.0'
59+
}
60+
61+
wrapper {
62+
gradleVersion = '4.10.2'
2663
}
2764

2865
compileJava {
@@ -34,10 +71,7 @@ compileTestJava {
3471
sourceCompatibility = 1.8
3572
}
3673

37-
jar {
38-
baseName = 'web-push'
39-
version = '3.1.1'
40-
}
74+
mainClassName = 'nl.martijndwars.webpush.cli.Cli'
4175

4276
shadowJar {
4377
// BouncyCastle JAR is signed; it cannot be extracted and merged into the fat JAR.
@@ -47,15 +81,15 @@ shadowJar {
4781
)
4882
}
4983
manifest {
50-
attributes 'Main-Class': 'nl.martijndwars.webpush.cli.Cli',
51-
'Class-Path': '../../lib/bcprov-jdk15on-154.jar'
84+
attributes 'Class-Path': '../../lib/bcprov-jdk15on-154.jar'
5285
}
5386
}
5487

55-
junitPlatform {
56-
selectors {
57-
aClass 'nl.martijndwars.webpush.selenium.SeleniumTests'
58-
}
88+
test {
89+
useJUnitPlatform()
90+
91+
// TODO: Make the other test proper unit tests and remove this filter.
92+
include '**/SeleniumTests.class'
5993
}
6094

6195
task javadocJar(type: Jar) {
@@ -71,97 +105,3 @@ task sourcesJar(type: Jar) {
71105
artifacts {
72106
archives javadocJar, sourcesJar
73107
}
74-
75-
signing {
76-
sign configurations.archives
77-
}
78-
79-
uploadArchives {
80-
repositories {
81-
mavenDeployer {
82-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
83-
84-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
85-
authentication(
86-
userName: project.hasProperty('ossrhPassword') ? ossrhUsername : '',
87-
password: project.hasProperty('ossrhPassword') ? ossrhPassword : ''
88-
)
89-
}
90-
91-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
92-
authentication(
93-
userName: project.hasProperty('ossrhPassword') ? ossrhUsername : '',
94-
password: project.hasProperty('ossrhPassword') ? ossrhPassword : ''
95-
)
96-
}
97-
98-
pom.project {
99-
name 'web-push'
100-
packaging 'jar'
101-
description 'A Web Push library for Java.'
102-
url 'https://github.com/web-push-libs/webpush-java'
103-
104-
scm {
105-
connection 'scm:git:[email protected]:web-push-libs/webpush-java.git'
106-
developerConnection 'scm:git:[email protected]:web-push-libs/webpush-java.git'
107-
url '[email protected]:web-push-libs/webpush-java.git'
108-
}
109-
110-
licenses {
111-
license {
112-
name 'MIT License'
113-
url 'https://opensource.org/licenses/MIT'
114-
}
115-
}
116-
117-
developers {
118-
developer {
119-
id 'martijndwars'
120-
name 'Martijn Dwars'
121-
122-
}
123-
}
124-
}
125-
}
126-
}
127-
}
128-
129-
repositories {
130-
mavenLocal()
131-
mavenCentral()
132-
}
133-
134-
dependencies {
135-
// For CLI
136-
compile group: 'com.beust', name: 'jcommander', version: '1.72'
137-
138-
// For parsing JSON
139-
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
140-
141-
// For making async HTTP requests
142-
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.3'
143-
144-
// For cryptographic operations
145-
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.54'
146-
147-
// For creating and signing JWT
148-
compile group: 'org.bitbucket.b_c', name: 'jose4j', version: '0.5.2'
149-
150-
// For making HTTP requests
151-
testCompile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.2'
152-
153-
// For testing, obviously
154-
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.0.0-M4'
155-
156-
// For running JUnit tests
157-
testRuntime group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.0.0-M4'
158-
159-
// For turning InputStream to String
160-
testCompile group: 'commons-io', name: 'commons-io', version: '2.5'
161-
162-
// For reading the demo vapid keypair from a pem file
163-
testCompile group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.55'
164-
165-
// For verifying Base64Encoder results in unit tests
166-
testCompile group: 'com.google.guava', name: 'guava', version: '19.0'
167-
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon May 29 11:45:53 PDT 2017
1+
#Sun Sep 30 11:51:22 CEST 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip

release.gradle

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
signing {
2+
sign configurations.archives
3+
}
4+
5+
uploadArchives {
6+
repositories {
7+
mavenDeployer {
8+
beforeDeployment { MavenDeployment deployment ->
9+
signing.signPom(deployment)
10+
}
11+
12+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
13+
authentication(
14+
userName: ossrhUsername,
15+
password: ossrhPassword
16+
)
17+
}
18+
19+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
20+
authentication(
21+
userName: ossrhUsername,
22+
password: ossrhPassword
23+
)
24+
}
25+
26+
pom.project {
27+
name 'web-push'
28+
packaging 'jar'
29+
description 'A Web Push library for Java.'
30+
url 'https://github.com/web-push-libs/webpush-java'
31+
32+
scm {
33+
connection 'scm:git:[email protected]:web-push-libs/webpush-java.git'
34+
developerConnection 'scm:git:[email protected]:web-push-libs/webpush-java.git'
35+
url '[email protected]:web-push-libs/webpush-java.git'
36+
}
37+
38+
licenses {
39+
license {
40+
name 'MIT License'
41+
url 'https://opensource.org/licenses/MIT'
42+
}
43+
}
44+
45+
developers {
46+
developer {
47+
id 'martijndwars'
48+
name 'Martijn Dwars'
49+
50+
}
51+
}
52+
}
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)