maven2Gradle task in Gradle 1.6-rc1

Hi,

I was trying out the build setup plugin in Gradle 1.6-rc1 to generate a Maven POM via the maven2Gradle task. The current directory contains a pom.xml with the following content:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.mycompany.app</groupId>
   <artifactId>my-app</artifactId>
   <packaging>jar</packaging>
   <version>1.0</version>
     <dependencies>
      <dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-lang3</artifactId>
         <version>3.1</version>
         <scope>compile</scope>
      </dependency>
   </dependencies>
</project>

When I run the gradle tasks the only task presented is this one:

Build Setup tasks
-----------------
setupBuild - Initializes a new Gradle build. [incubating]

Based on the design doc shouldn’t the build setup provide the maven2Gradle task or am I missing something?

Thanks,

Ben

The maven2Gradle task depends on the setupBuild task. you should see the task when running gradle tasks --all

cheers, René

Thanks, that works! I had already tried out the task with an earlier version of Gradle. I know that the task is at an early stage of development. Two things stood out in the generated pom.xml that might be a bug.

  1. If a description or no description is provided in the POM, an empty multi-line String is added.
description = """"""
  1. The generated repositories configuration block looks like this:
repositories {
       mavenRepo url: "http://someRepo"
}

Shouldn’t this be:

repositories {
     mavenCentral()
}

Any ideas?

thanks for pointing this out. The maven2Gradle converter uses the mavenRepo syntax when a repository is explicitly declared in the pom. Otherwise the mavenCentral() shortcut notation is used. I have to doublecheck how the description is generated. After a first view the name property of the effective pom is used as description.

cheers, René

Would probably be better to use the new ‘maven’ instead of the old ‘mavenRepo’ syntax.

agreed. I thought, the ‘mavenRepo’ syntax is deprecated, but from what I can see, this isn’t the case.

Ah, I get it. The converter was using the repository URL defined in my Maven profile in ~/.m2/settings.xml.