29

I'm looking for some Gradle executor plugin for Maven (similar to Maven ant-run plugin).
Google did not help.

Is it possible that such plugin doesn't exist?

ice1000
  • 6,406
  • 4
  • 39
  • 85
orshachar
  • 4,837
  • 14
  • 45
  • 68
  • The question is why do you need such thing? What would you like to achieve? – khmarbaise Jun 02 '13 at 13:16
  • I want to create a dynamic modules that offers a set of actions and by different profiles it will execute different subset of it's actions. currently - Maven does not support it (everything is bound to lifecycle). Ant and Gradle can, and I rather use gradle. Also - I havea a big Maven project so I can't transform the whole project into Gradle. – orshachar Jun 02 '13 at 14:01
  • What kind of actions? Maven has profiles as well. May be you can elaborate a little bit more? Is this project public available ? – khmarbaise Jun 02 '13 at 14:11
  • Let 1,2,3,4,5,6 be atomic actions. Say we have several flows A B C D. Flow A needs to do : 1-6; Flow B needs to do: 2,4,6; Flow C needs to do 6,1,2,3 etc... Ant gives a perfect solution to it while Maven requires profile duplication since you can't dynamically select which profiles to execute. http://stackoverflow.com/questions/5417437/activation-of-maven-profile-based-on-multiple-properties – orshachar Jun 04 '13 at 07:50
  • @khmarbaise lots of reasons, maven is faster, more mature, more plugins and thus more capabilities. Gradle is just a slower clone of Ant mixed with dependency management that uses maven. – spy Jul 24 '15 at 17:30
  • @khmarbaise - another reason to do this is if your project sits in a build infrastructure centered on Maven, one that you cannot simply change it.Yet you want to rewrite the project's build guts to Gradle. So you could do that and then rewrite its existing pom to be just a bridge between the maven-centric build infrastructure and your new gradle build under the hoods. – luis.espinal Mar 28 '19 at 16:41

2 Answers2

25

I should try this: https://github.com/if6was9/gradle-maven-plugin

This is a maven plugin that makes it easy to invoke gradle from maven.

It is similar to the maven-antrun-plugin that allows ant to be invoked from maven.

orshachar
  • 4,837
  • 14
  • 45
  • 68
  • 5
    That plugin is dead now. Use this fork instead: https://github.com/raphw/gradle-maven-plugin – treaz Jul 30 '18 at 12:57
2

I probably would use:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
      <execution>
        <id>test</id>
        <phase>test</phase>
        <configuration>
          <executable>./gradlew</executable>
          <arguments>
            <argument>test</argument>
            <argument>-i</argument>
          </arguments>
        </configuration>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
      <execution>
        <id>install</id>
        <phase>install</phase>
        <configuration>
          <executable>./gradlew</executable>
          <arguments>
            <argument>install</argument>
          </arguments>
        </configuration>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Because of the following reasons:

  1. I would prefer to trust in a plugin maintained by Codehaus.
  2. If you use the gradle-maven-plugin, probably you'll have to configure additional information in your settings.xml. Otherwise this error can occur: Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8
Felipe Desiderati
  • 2,414
  • 3
  • 24
  • 42