如何在MAVEN中使用pom.xml运行LoadFromFile命令?

时间:2013-06-27 07:09:03

标签: maven

我正在开发一个名为Windchill的工具。我准备了一个构建来通过xml文件加载一些属性。要加载这些xml文件,我使用以下命令。

例如:windchill wt.load.LoadFromFile -d C:\ ptc \ Windchill_10.1 \ Windchill \ loadFiles \ pdmlink \ itc \ attributes \ Attributes.xml -u wcadmin -p wcadmin

像这样我在windchill命令提示符下手动运行了100个命令。因此,我基本上希望通过使用MAVEN顺序执行这些命令来自动化该过程,而无需任何手动工作。

有没有办法部署此版本。请帮忙。

感谢。

2 个答案:

答案 0 :(得分:2)

我建议你看一下exec-maven-plugin,它似乎是你想要达到的目标的正确选择。

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            ...
            <phase>WhatEver</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>windchill </executable>
          <!-- optional -->
          <workingDirectory>/tmp</workingDirectory>
          <arguments>
            <argument>wt.load.LoadFromFile</argument>
            <argument>and so on</argument>
            ...
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>
   ...
</project>

答案 1 :(得分:0)

    <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>Build</groupId>
    <artifactId>Build_SMB</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>
    <name>SMB PROJECT</name>
    <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <phase>deploy</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>windchill</executable>
          <!-- optional -->
          <workingDirectory>C:/mvn/test</workingDirectory>
          <arguments>
            <argument>wt.load.LoadFromFile</argument>
            <argument>-d</argument>
            <argument>C:/ptc/Windchill_10.1/Windchill/loadFiles/pdmlink/itc/attributes/Attributes.xml</argument>
            <argument>-u</argument>
            <argument>wcadmin</argument>
            <argument>-p</argument>
            <argument>wcadmin</argument>
          </arguments>
           <systemProperties>
            <systemProperty>
              <key>WT_HOME</key>
              <value>${env.WT_HOME}</value>
            </systemProperty>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
相关问题