简体   繁体   English

我怎样才能Windows命令提示符从Maven pom.xml文件?

[英]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. 我正在制作一个试图运行命令提示符命令的Maven项目。 I tried Exec Maven Plugin but couldn't do it. 我尝试了Exec Maven插件,但是做不到。 I think i'm at wrong way for this. 我认为我为此错误。 Here is my work for making a file with "Exec Maven Plugin". 这是我使用“ Exec Maven插件”制作文件的工作。 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). 有人可以解释为什么这样不起作用,也可以对在pom.xml(不是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. 您可以创建一个bash / batch脚本并尝试执行该命令,而不是直接执行命令。 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. 基本上是同一回事,但是您可以在脚本中使用常规语法,而不是POM文件中的XML语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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