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

问题描述 投票:0回答:2

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

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

像这样,我有大约 100 个命令需要在 Windchill 命令提示符下手动运行。所以我基本上想通过使用 MAVEN 顺序执行这些命令来自动化该过程,而无需任何手动工作。

有什么方法可以部署这个构建吗?请帮忙。

谢谢。

maven
2个回答
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>

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>
© www.soinside.com 2019 - 2024. All rights reserved.