简体   繁体   中英

How can i windows command prompt commands from maven pom.xml file?

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..

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM