Skip to content

Commit 40c8e1c

Browse files
committed
feat: produce a standalone jar without dependencies (refs #98)
1 parent c5af3b7 commit 40c8e1c

File tree

68 files changed

+103
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+103
-76
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
id: publish_package
2828
uses: gradle/[email protected]
2929
with:
30-
arguments: -Pversion=${{ steps.new_version.outputs.new_version }} publish closeAndReleaseStagingRepository -x publishStandaloneJarPublicationToGitHubPackagesRepository -x publishStandaloneJarPublicationToSonatypeRepository
30+
arguments: -Pversion=${{ steps.new_version.outputs.new_version }} publish closeAndReleaseStagingRepository
3131
env:
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333
OSSRH_USERNAME: ${{ vars.MAVEN_CENTRAL_USERNAME }}

build.gradle

Lines changed: 68 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,79 @@
11
plugins {
2-
id "se.bjurr.gradle.java-convention" version "0.+"
3-
id "org.wiremock.tools.gradle.publishing" version "0.5.1"
4-
id "org.wiremock.tools.gradle.java" version "0.5.1"
5-
id "project-report"
2+
id "se.bjurr.gradle.bundle-jar" version "1.4.2"
63
}
74

8-
sourceCompatibility = 17
9-
targetCompatibility = 17
10-
11-
group 'org.wiremock.integrations'
12-
13-
jar {
14-
manifest {
15-
attributes 'name': project.name
16-
attributes 'Automatic-Module-Name': project.group + "." + project.name
5+
allprojects {
6+
javaExtension {
7+
javaVersion = 17
178
}
189
}
1910

20-
// Because older version is set in wiremock-extension-convention
21-
def wiremockVersion = "3.13.1"
11+
releaseExtension {
12+
nexusUsernameEnvOrProp = "OSSRH_USERNAME"
13+
nexusPasswordEnvOrProp = "OSSRH_TOKEN"
14+
}
2215

23-
configurations {
24-
all*.exclude group: 'org.eclipse.jetty', module: 'jetty-servlet'
25-
all*.exclude group: 'org.eclipse.jetty', module: 'jetty-servlets'
26-
all*.exclude group: 'org.eclipse.jetty', module: 'jetty-webapp'
27-
all*.exclude group: 'org.eclipse.jetty.http2', module: 'http2-server'
16+
signExtension {
17+
signingKeyEnvOrProp = "OSSRH_GPG_SECRET_KEY"
18+
signingPasswordEnvOrProp = "OSSRH_GPG_SECRET_KEY_PASSWORD"
2819
}
2920

30-
dependencies {
31-
implementation platform("org.eclipse.jetty:jetty-bom:12.0.15")
32-
api "org.wiremock:wiremock-jetty12:${wiremockVersion}"
33-
api "org.springframework.boot:spring-boot-test:3.4.1"
34-
api "org.springframework:spring-test:6.1.13"
35-
api "org.slf4j:slf4j-api:2.0.16"
36-
api 'org.junit.jupiter:junit-jupiter-api:5.11.2'
37-
38-
testImplementation "org.wiremock:wiremock-jetty12:${wiremockVersion}"
39-
testImplementation "org.springframework.boot:spring-boot-starter-test:3.4.1"
40-
testImplementation 'org.assertj:assertj-core:3.27.4'
41-
testImplementation platform('org.junit:junit-bom:5.11.2')
42-
testImplementation 'org.junit.jupiter:junit-jupiter'
43-
testImplementation 'org.junit.platform:junit-platform-launcher'
44-
testImplementation 'io.rest-assured:rest-assured:5.5.0'
45-
testImplementation 'io.rest-assured:rest-assured:5.5.0'
46-
testImplementation "org.springframework.boot:spring-boot-starter-web:3.4.1"
47-
testImplementation 'io.cucumber:cucumber-java:7.20.1'
48-
testImplementation 'io.cucumber:cucumber-spring:7.20.1'
49-
testImplementation 'io.cucumber:cucumber-junit-platform-engine:7.20.1'
50-
testImplementation 'org.junit.platform:junit-platform-suite:1.11.4'
51-
testImplementation 'org.assertj:assertj-core:3.27.4'
52-
53-
constraints {
54-
implementation('org.apache.commons:commons-compress:1.26.0') {
55-
because 'version 1.24.0 has a vulnerability'
21+
project("wiremock-spring-boot", {
22+
dependencies {
23+
implementation platform("org.eclipse.jetty:jetty-bom:12.1.0")
24+
implementation "org.eclipse.jetty.ee10:jetty-ee10-bom:12.1.0"
25+
api "org.wiremock:wiremock-jetty12:3.13.1"
26+
api "org.springframework.boot:spring-boot-test:3.4.1"
27+
api "org.springframework:spring-test:6.1.13"
28+
api "org.slf4j:slf4j-api:2.0.16"
29+
api 'org.junit.jupiter:junit-jupiter-api:5.11.2'
30+
31+
testImplementation "org.wiremock:wiremock-jetty12:3.13.1"
32+
testImplementation "org.springframework.boot:spring-boot-starter-test:3.4.1"
33+
testImplementation 'org.assertj:assertj-core:3.27.4'
34+
testImplementation platform('org.junit:junit-bom:5.11.2')
35+
testImplementation 'org.junit.jupiter:junit-jupiter'
36+
testImplementation 'org.junit.platform:junit-platform-launcher'
37+
testImplementation 'io.rest-assured:rest-assured:5.5.0'
38+
testImplementation 'io.rest-assured:rest-assured:5.5.0'
39+
testImplementation "org.springframework.boot:spring-boot-starter-web:3.4.1"
40+
testImplementation 'io.cucumber:cucumber-java:7.20.1'
41+
testImplementation 'io.cucumber:cucumber-spring:7.20.1'
42+
testImplementation 'io.cucumber:cucumber-junit-platform-engine:7.20.1'
43+
testImplementation 'org.junit.platform:junit-platform-suite:1.11.4'
44+
testImplementation 'org.assertj:assertj-core:3.27.4'
45+
46+
constraints {
47+
implementation('org.apache.commons:commons-compress:1.26.0') {
48+
because 'version 1.24.0 has a vulnerability'
49+
}
5650
}
5751
}
58-
}
52+
})
53+
54+
project("wiremock-spring-boot-standalone", {
55+
apply plugin: 'se.bjurr.gradle.shadow'
56+
57+
shadowJar {
58+
relocate "org.wiremock", 'wiremock.org.wiremock'
59+
relocate "org", 'wiremock.org'
60+
relocate "com.google", 'wiremock.com'
61+
relocate "net.minidev", 'wiremock.net'
62+
relocate "jakarta.servlet", "wiremock.jakarta"
63+
relocate "joptsimple", "wiremock.joptsimple"
64+
exclude 'joptsimple/HelpFormatterMessages.properties'
65+
66+
mergeServiceFiles()
67+
68+
exclude 'META-INF/maven/**'
69+
exclude 'META-INF/versions/17/**'
70+
exclude 'META-INF/versions/21/**'
71+
exclude 'META-INF/versions/22/**'
72+
exclude 'module-info.class'
73+
exclude 'handlebars-*.js'
74+
}
75+
76+
dependencies {
77+
implementation project(":wiremock-spring-boot")
78+
}
79+
})

gradle.properties

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
#Sun Oct 06 08:21:20 CEST 2024
22
description=WireMock integration for Spring Boot.
3-
sourceCompatibility=17
4-
targetCompatibility=17
3+
group=org.wiremock.integrations
54
version=3.0.0
6-
baseArtifact=wiremock-spring-boot
7-
githubRepo=wiremock-spring-boot
8-
developer.id=tomasbjerre
9-
developer.name=Tomas Bjerre
10-
developer.email=[email protected]
11-
useShadowJar=false

gradle/wrapper/gradle-wrapper.jar

1.95 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -112,7 +114,6 @@ case "$( uname )" in #(
112114
NONSTOP* ) nonstop=true ;;
113115
esac
114116

115-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
116117

117118

118119
# Determine the Java command to use to start the JVM.
@@ -170,7 +171,6 @@ fi
170171
# For Cygwin or MSYS, switch paths to Windows format before running java
171172
if "$cygwin" || "$msys" ; then
172173
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
173-
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
174174

175175
JAVACMD=$( cygpath --unix "$JAVACMD" )
176176

@@ -203,15 +203,14 @@ fi
203203
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204204

205205
# Collect all arguments for the java command:
206-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207207
# and any embedded shellness will be escaped.
208208
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209209
# treated as '${Hostname}' itself on the command line.
210210

211211
set -- \
212212
"-Dorg.gradle.appname=$APP_BASE_NAME" \
213-
-classpath "$CLASSPATH" \
214-
org.gradle.wrapper.GradleWrapperMain \
213+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
215214
"$@"
216215

217216
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -68,11 +70,10 @@ goto fail
6870
:execute
6971
@rem Setup the command line
7072

71-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7273

7374

7475
@rem Execute Gradle
75-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7677

7778
:end
7879
@rem End local scope for the variables with windows NT shell

settings.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ pluginManagement {
66
}
77
}
88

9-
rootProject.name = 'wiremock-spring-boot'
9+
plugins {
10+
id "se.bjurr.gradle.include-virtual" version "1.0.0"
11+
}
12+
13+
rootProject.name = 'wiremock-spring-boot-base'
14+
15+
includeVirtual "wiremock-spring-boot", "wiremock-spring-boot-standalone"

0 commit comments

Comments
 (0)