Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to publish to local maven repo when using Gradle and Spring Boot

I have a very simple spring-boot (1.0.2) example (based on http://spring.io/guides/gs/rest-service/) using Gradle (1.12) to create a jar file.

I'm trying to build and publish to my local maven repo using either the maven or maven-publish gradle plugins but am getting the error:

Unable to initialize POM pom-default.xml: Failed to validate POM for project ngdc.sample:hello-springboot at /Users/jcc/Documents/stash/hello-springboot/build/poms/pom-default.xml

and don't understand why. version, group, and archivesBaseName are all specified in the build.gradle. A similar project which doesn't rely on SpringBoot works fine.

Can someone suggest what the problem might be?

Thanks!

--john

like image 521
John Cartwright Avatar asked May 14 '14 22:05

John Cartwright


People also ask

Does Gradle use Maven local repository?

Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project. Gradle stores resolved dependencies in its own cache.


2 Answers

You might need to ensure that the parent pom or dependency management is specified as well (depends on your configuration, but if you are using the Spring Boot Gradle plugin you probably do need it). Example here: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/resources/installer.gradle

install {
    repositories.mavenInstaller {
        pom.project {
          parent { 
            groupId 'org.springframework.boot'
            artifactId 'spring-boot-starter-parent'
            version "${project.bootVersion}"
          }
        }
    }
}
like image 74
Dave Syer Avatar answered Oct 13 '22 12:10

Dave Syer


When the Spring Boot Gradle Plugin without dependency versions in the dependency{...} section, the pom is generated without version for Spring Boot etc.

So at the moment it's required to create the relation to the parent pom by yourself for all maven realted tasks parent { groupId 'org.springframework.boot' artifactId 'spring-boot-starter-parent' version "${project.bootVersion}" }

See https://github.com/spring-projects/spring-boot/issues/1716

like image 37
joo Avatar answered Oct 13 '22 10:10

joo