Skip to content

Commit

Permalink
chore: restructuring project to make rootProject main artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Sep 29, 2024
1 parent da6315d commit afc034d
Show file tree
Hide file tree
Showing 38 changed files with 78 additions and 113 deletions.
171 changes: 64 additions & 107 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,119 +1,76 @@
buildscript {
repositories {
maven { url "https://oss.sonatype.org" }
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
}
dependencies {
classpath "org.wiremock.tools.gradle:extension-convention-plugin:0.3.0"
classpath 'se.bjurr.gitchangelog:git-changelog-lib:1.175.2'
}
repositories {
maven { url "https://oss.sonatype.org" }
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'se.bjurr.gitchangelog:git-changelog-lib:1.175.2'
classpath "org.wiremock.tools.gradle:gradle-wiremock-extension-plugins:latest-SNAPSHOT"
classpath "se.bjurr.gradle:java-convention-gradle-plugin:latest-SNAPSHOT"
classpath "se.bjurr.gradle:update-versions-gradle-plugin:latest-SNAPSHOT"
}
}

plugins {
id 'idea'
id 'eclipse'
id 'project-report'
id 'com.diffplug.spotless' version '6.25.0'
id 'org.wiremock.tools.gradle.wiremock-extension-convention' version '0.3.0'
}

def bumpVersionTo(version) {
def propertyFile = new File("$projectDir/gradle.properties")
def gradleProps = new Properties()
propertyFile.withReader { gradleProps.load(it) }
def currentVersion = gradleProps.getProperty("version")
if (currentVersion == version) {
logger.lifecycle("Version not changed (${currentVersion})")
} else {
logger.lifecycle("Version changed (${currentVersion} -> ${version})")
gradleProps.setProperty('version', version)
propertyFile.withWriter { gradleProps.store(it, null) }
}
}

task setConventionalVersion() {
doFirst {
def nextVersion = se.bjurr.gitchangelog.api.GitChangelogApi.gitChangelogApiBuilder()
.withFromRepo(file('.'))
.withSemanticMajorVersionPattern("^[Bb]reak")
.withSemanticMinorVersionPattern("^[Ff]eat")
.getNextSemanticVersion()
.getVersion();
def nextSnapshot = "${nextVersion}-SNAPSHOT"
bumpVersionTo(nextSnapshot)
}
}
build.dependsOn setConventionalVersion
apply plugin: 'project-report'
apply plugin: 'org.wiremock.tools.gradle.wiremock-extension-convention'

allprojects {
repositories {
mavenLocal()
mavenCentral()
}

apply plugin: 'java-library'
sourceCompatibility = 17
targetCompatibility = 17
apply plugin: 'se.bjurr.gradle.java-convention'
apply plugin: 'se.bjurr.gradle.update-versions'

apply plugin: 'com.diffplug.spotless'
spotless {
java {
target 'src/**/*.java'
googleJavaFormat('1.17.0')
ratchetFrom 'origin/main'
trimTrailingWhitespace()
endWithNewline()
targetExclude '**/Tmp*.java'
}
groovyGradle {
target '**/*.gradle'
greclipse()
indentWithSpaces(2)
trimTrailingWhitespace()
endWithNewline()
}
json {
target 'src/**/*.json'
targetExclude '**/tmp*.json', 'src/test/resources/sample.json', 'src/main/resources/swagger/*.json', 'src/test/resources/filesource/subdir/deepfile.json', 'src/test/resources/schema-validation/*.json'
simple().indentWithSpaces(2)
}
}

test {
useJUnitPlatform()
testLogging {
events "PASSED", "FAILED", "SKIPPED"
exceptionFormat "full"
}
}
dependencies {
testImplementation "org.springframework.boot:spring-boot-starter-test:3.3.4"
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation platform('org.junit:junit-bom:5.10.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.platform:junit-platform-launcher'
}
}

dependencies {
testImplementation "org.springframework.boot:spring-boot-starter-test:3.3.4"
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation platform('org.junit:junit-bom:5.10.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.platform:junit-platform-launcher'
}
dependencies {
api 'org.wiremock:wiremock-standalone:3.9.1'
api "org.springframework.boot:spring-boot-test:3.3.4"
api "org.springframework:spring-test:6.1.13"
api "org.slf4j:slf4j-api:2.0.16"
api "org.junit.jupiter:junit-jupiter-api:5.11.0"
}

project('wiremock-spring-boot', {
dependencies {
api 'org.wiremock:wiremock-standalone:3.9.1'
api "org.springframework.boot:spring-boot-test:3.3.4"
api "org.springframework:spring-test:6.1.13"
api "org.slf4j:slf4j-api:2.0.16"
api "org.junit.jupiter:junit-jupiter-api:5.11.0"
compileOnly "com.github.spotbugs:spotbugs-annotations:4.8.6"
}
project('wiremock-spring-boot-example', {
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web:3.3.4"
implementation "org.springframework.boot:spring-boot-starter-webflux:3.3.4"

testImplementation rootProject
testImplementation 'io.rest-assured:rest-assured:5.5.0'
}
})

project('example', {
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web:3.3.4"
implementation "org.springframework.boot:spring-boot-starter-webflux:3.3.4"
def bumpVersionTo(version) {
def propertyFile = new File("$projectDir/gradle.properties")
def gradleProps = new Properties()
propertyFile.withReader { gradleProps.load(it) }
def currentVersion = gradleProps.getProperty("version")
if (currentVersion == version) {
logger.lifecycle("Version not changed (${currentVersion})")
} else {
logger.lifecycle("Version changed (${currentVersion} -> ${version})")
gradleProps.setProperty('version', version)
propertyFile.withWriter { gradleProps.store(it, null) }
}
}

testImplementation project(':wiremock-spring-boot')
testImplementation 'io.rest-assured:rest-assured:5.5.0'
}
})
task setConventionalVersion() {
doFirst {
def nextVersion = se.bjurr.gitchangelog.api.GitChangelogApi.gitChangelogApiBuilder()
.withFromRepo(file('.'))
.withSemanticMajorVersionPattern("^[Bb]reak")
.withSemanticMinorVersionPattern("^[Ff]eat")
.getNextSemanticVersion()
.getVersion();
def nextSnapshot = "${nextVersion}-SNAPSHOT"
bumpVersionTo(nextSnapshot)
}
}
build.dependsOn setConventionalVersion
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ description=WireMock integration for Spring Boot.
developer.name=Tomas Bjerre
developer.email=[email protected]
version=3.0.0-SNAPSHOT
group=org.wiremock.spring
sourceCompatibility=17
targetCompatibility=17
useShadow=false
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = 'wiremock-spring-boot-parent'
include 'wiremock-spring-boot', 'example'
rootProject.name = 'wiremock-spring-boot'
include 'wiremock-spring-boot-example'
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"url": "/"
},
"response": {
"headers": {"Content-Type": "application/json"},
"headers": {
"Content-Type": "application/json"
},
"jsonBody": [
{
"id": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"url": "/1"
},
"response": {
"headers": {"Content-Type": "application/json"},
"headers": {
"Content-Type": "application/json"
},
"jsonBody": {
"name": "Jenna",
"id": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"url": "/wiremockmappingsmock"
},
"response": {
"jsonBody": {"wiremockmappingsmock": "yes"},
"jsonBody": {
"wiremockmappingsmock": "yes"
},
"status": 200
}
}

0 comments on commit afc034d

Please sign in to comment.