Add task for deploying artifacts to Nexus

This commit is contained in:
Mihailo Marcetic 2025-01-31 18:28:10 +01:00
parent c7dd21af0f
commit 22eac78c28
2 changed files with 42 additions and 1 deletions

2
.gitignore vendored
View file

@ -49,3 +49,5 @@ out/
_site/ _site/
*.css *.css
!petclinic.css !petclinic.css
gradle.properties

View file

@ -7,6 +7,7 @@ plugins {
id 'io.spring.javaformat' version '0.0.43' id 'io.spring.javaformat' version '0.0.43'
id "io.spring.nohttp" version "0.0.11" id "io.spring.nohttp" version "0.0.11"
id("pl.allegro.tech.build.axion-release") version "1.18.7" id("pl.allegro.tech.build.axion-release") version "1.18.7"
id('maven-publish')
} }
version = scmVersion.version version = scmVersion.version
@ -20,14 +21,42 @@ gradle.startParameter.excludedTaskNames += [ "checkFormatAot", "checkFormatAotTe
group = 'org.springframework.samples' group = 'org.springframework.samples'
version = '3.4.0' version = '3.4.0'
def nexusUsername = project.hasProperty('nexusUsername') ? project.nexusUsername : System.getenv('NEXUS_USERNAME')
def nexusPassword = project.hasProperty('nexusPassword') ? project.nexusPassword : System.getenv('NEXUS_PASSWORD')
java { java {
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17
} }
repositories { repositories {
mavenCentral() maven {
url 'http://localhost:8081/repository/maven-central/'
allowInsecureProtocol = true
}
mavenCentral()
} }
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact file("build/libs/spring-application-${version}.jar")
}
}
repositories {
maven {
name = "maven-releases"
url 'http://localhost:8081/repository/maven-releases/'
allowInsecureProtocol = true
credentials {
username nexusUsername
password nexusPassword
}
}
}
}
ext.checkstyleVersion = "10.20.1" ext.checkstyleVersion = "10.20.1"
ext.springJavaformatCheckstyleVersion = "0.0.43" ext.springJavaformatCheckstyleVersion = "0.0.43"
ext.webjarsLocatorLiteVersion = "1.0.1" ext.webjarsLocatorLiteVersion = "1.0.1"
@ -61,6 +90,7 @@ dependencies {
testImplementation 'org.testcontainers:mysql' testImplementation 'org.testcontainers:mysql'
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${springJavaformatCheckstyleVersion}" checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${springJavaformatCheckstyleVersion}"
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}" checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
testImplementation 'junit:junit:4.13'
} }
tasks.named('test') { tasks.named('test') {
@ -107,6 +137,15 @@ task openTestResults(dependsOn: ['build', 'test']) {
} }
} }
task testProxy {
doLast {
def url = new URL('http://localhost:8081/repository/maven-central')
def connection = url.openConnection()
connection.connect()
println "Proxy connection successful to Maven Central!"
}
}
checkstyleAot.enabled = false checkstyleAot.enabled = false
checkstyleAotTest.enabled = false checkstyleAotTest.enabled = false