1

Im trying to convert an autogenerated pom.xml from (https://start.spring.io) online tool to gradle.

I have Java gradle project that needs some features in Spring boot.

(https://start.spring.io) online tool generates this pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>gov.nasa.jpl.ccsds.oais.if_prototype</groupId>
    <artifactId>OaisInteropFramework</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>OaisInteropFramework</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

After issuing "gradle init", based on this blog (https://howtodoinjava.com/gradle/convert-maven-project-to-gradle-project/) the pom.xml is suppose to be converted to gradle projet.

It seems several gradle files are created however gradle.build is empty & there is an error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':init'.
> Could not convert Maven POM C:\Users\xyz\Documents\NetBeansProjects\test_pom\pom.xml to a Gradle build.
   > Unable to create Maven project model using POM C:\Users\xyz\Documents\NetBeansProjects\test_pom\pom.xml.
      > 1 problem was encountered while building the effective model for com.abc.defccsds.oais.if_prototype:OaisInteropFramework:0.0.1-SNAPSHOT
        [FATAL] Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.4.0.RELEASE from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.4.0.RELEASE/spring-boot-starter-parent-2.4.0.RELEASE.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. and 'parent.relativePath' points at no local POM @ line 5, column 10
         for project com.abc.defccsds.oais.if_prototype:OaisInteropFramework:0.0.1-SNAPSHOT at C:\Users\xyz\Documents\NetBeansProjects\test_pom\pom.xml

How can I get back a proper gradle.build from pom , hopefully automatically using gradle init?

6
  • Is there a particular reason not just to generate a new Gradle project from Initializr? Commented May 18, 2020 at 23:38
  • 1
    Problem is that gradle could not fetch artifacts because maven central repository requires https . To fix this problem try defining repository tag in your pom and use https "repo1.maven.org/maven2" Ref: maven.apache.org/guides/introduction/…, in error it clearly says "ReasonPhrase:HTTPS Required" Commented May 18, 2020 at 23:49
  • @user2880879, so do I need to create ssl key on my side, etc.. based on maven.apache.org/guides/mini/guide-repository-ssl.html. Is there a rep that doenst require https?
    – cyber101
    Commented May 19, 2020 at 1:05
  • Just create a gradle project and use the gradle wrapper to run the scripts (or use a recent version of gradle if you want to use a global gradle installation). The scripts provided by the initializer work, at least with the gradle wrapper supplied with it.
    – M. Deinum
    Commented May 19, 2020 at 5:55
  • The release given 2.4.0.RELEASE does not exist yet...the most recent version of Spring Boot is 2.3.0.RELEASE...
    – khmarbaise
    Commented May 19, 2020 at 7:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.