0

I am making a maven project which is trying to run command prompt commands. I tried Exec Maven Plugin but couldn't do it. I think i'm at wrong way for this. Here is my work for making a file with "Exec Maven Plugin". Can someone make an explanation why this is not working or make a suggestion about new plugin or solution which is working at pom.xml (not Ant).

 `<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>mkdir</executable>
                <arguments>
                    <argument>C:\Users\USERNAME\Desktop\FILENAME</argument>
                </arguments>
            </configuration>
        </plugin>
    </plugins>
</build>`

Thank You..

Brian S
  • 3,096
  • 37
  • 55
Erçin Akçay
  • 1,383
  • 4
  • 18
  • 34

1 Answers1

1

This is just a workaround you can try until someone comes up with a better answer. (I will remove it afterwards probably)

Instead of executing commands directly, you can create a bash/batch script and try to execute that. For example:

<execution>
  <id>Some ID</id>
  <phase>generate-sources</phase>
  <goals>
    <goal>exec</goal>
  </goals>
  <configuration>
    <executable>${basedir}/scripts/do_stuff.sh</executable>
  </configuration>
</execution>

It's basically the same thing, but you can use the normal syntax in the script, instead of the XML syntax in the POM file.

Dropout
  • 13,653
  • 10
  • 56
  • 109
  • Should i add special arguments at configuration tag for this solution? – Erçin Akçay Mar 31 '14 at 08:27
  • @ErçinAkçay if you're asking about the `${basedir}` variable, you can leave that out - that was just an example. The content of the executable tag can be just the absolute path to your script. – Dropout Mar 31 '14 at 08:35
  • This answer is really good but i need platform-independent solution for this one. For this reason trying to find out how can i run this maven but thanks for this too :) – Erçin Akçay Mar 31 '14 at 08:37
  • @ErçinAkçay Then you need a platform independent language - not Bash or Batch. Let's say for example Java ;) You can pack a JAR file and execute that instead. Anyway, I'm glad I could help at least a bit. Cheers! – Dropout Mar 31 '14 at 08:51