diff --git a/.gitignore b/.gitignore
index d2767ad28..6efcb93dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,3 +49,4 @@ out/
_site/
*.css
!petclinic.css
+gradle.properties
diff --git a/build.gradle b/build.gradle
index e6e8cfbc7..1eef5602b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,10 @@ plugins {
id 'io.spring.javaformat' version '0.0.43'
id "io.spring.nohttp" version "0.0.11"
id 'pl.allegro.tech.build.axion-release' version "1.18.7"
+ id 'maven-publish'
}
+// version '1.2'
+
version = scmVersion.version
apply plugin: 'java'
@@ -20,6 +23,8 @@ group = 'org.springframework.samples'
java {
sourceCompatibility = JavaVersion.VERSION_17
+ // archiveName = 'spring-petclinic'
+ // version = '0.1.3-SNAPSHOT'
}
repositories {
@@ -100,4 +105,44 @@ task showInBrowser {
}
tasks.named("showInBrowser").configure{ dependsOn ("build") }
-tasks.named("showInBrowser").configure{ dependsOn("test") }
\ No newline at end of file
+tasks.named("showInBrowser").configure{ dependsOn("test") }
+
+// Maven Publish Configuration
+
+def nexusUrl = 'http://localhost:8081/repository/maven-snapshots'
+def nexusUsername = project.hasProperty('nexusUsername') ? project.nexusUsername : System.getenv('NEXUS_USERNAME')
+def nexusPassword = project.hasProperty('nexusPassword') ? project.nexusPassword : System.getenv('NEXUS_PASSWORD')
+
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ from components.java
+
+ artifact file("${buildDir}/libs/spring-petclinic-${version}.jar")
+ }
+ }
+
+ repositories {
+ maven {
+ url nexusUrl
+ allowInsecureProtocol = true
+ credentials {
+ username nexusUsername
+ password nexusPassword
+ }
+ }
+ }
+}
+
+tasks.named("publish").configure{ dependsOn("build")}
+tasks.named("publish").configure{dependsOn("bootJar")}
+tasks.named("publishMavenJavaPublicationToMavenRepository").configure{ dependsOn("bootJar")}
+
+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!"
+ }
+}
diff --git a/pom.xml b/pom.xml
index 5c9848c49..7d9ef3048 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,6 +17,19 @@
spring-petclinic-4.0.2
+
+
+ nexus-releases
+ http://localhost:8081/repository/maven-releases/
+
+
+ nexus-snapshots
+ http://localhost:8081/repository/maven-snapshots/
+
+
+
+
+
org.springframework.samples
spring-petclinic
4.0.3-SNAPSHOT
@@ -287,8 +300,22 @@
false
-
+
+
+ org.sonatype.plugins
+ nxrm3-maven-plugin
+ 1.0.3
+ true
+
+ http://localhost:8081
+
+ nexus-snapshots
+
+ maven-snapshots
+
+ true
+
+
org.cyclonedx