Maven - antrun 插件无法创建任务或键入属性文件
Maven - antrun plugin failed to create task or ty pe propertyfile
我在尝试使用 Maven pom.xml 文件中的 antrun 插件更改 属性 文件内容时遇到以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (ant-create-properties
-file-content) on project SROTest: An Ant BuildException has occured: Problem: failed to create task or ty
pe propertyfile
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.PropertyFile was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME\lib
[ERROR] -the IDE Ant configuration dialogs
[ERROR]
[ERROR] Do not panic, this is a common problem.
[ERROR] The commonest cause is a missing JAR.
[ERROR]
[ERROR] This is not a bug; it is a configuration problem
[ERROR]
[ERROR] -> [Help 1]
这是我的 pom.xml 文件:
<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>com.mycompany</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<suiteFile></suiteFile>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>ant-create-properties-file-content</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<propertyfile file="test.properties">
<entry key="browser" value="chrome"/>
<entry key="run_on_grid" value="true"/>
<entry key="hub_address" value="selenium-hub.service.mycompany.mgmt"/>
<entry key="take_screenshots_on" value="true"/>
<entry key="highlight_on" value="true"/>
<entry key="recording_video_on" value="false"/>
<entry key="run_with_KLB" value="false"/>
<entry key="sut_url" value="http://aaa/weblink400/1/backoffice.app?noplugin=1"/>
</propertyfile>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
此脚本的目标是更改属性文件内容,当使用 ant build.xml 文件和 ant 命令(cmd 命令)执行它时,它按预期工作,但当尝试使用 maven 命令执行它时。我得到了上面显示的失败。
将依赖项作为 <dependency>
放在 <plugin>
下。
这应该是这样的:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>optional</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>ant-create-properties-file-content</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<propertyfile file="test.properties">
<entry key="browser" value="chrome"/>
<entry key="run_on_grid" value="true"/>
<entry key="hub_address" value="selenium-hub.service.mycompany.mgmt"/>
<entry key="take_screenshots_on" value="true"/>
<entry key="highlight_on" value="true"/>
<entry key="recording_video_on" value="false"/>
<entry key="run_with_KLB" value="false"/>
<entry key="sut_url" value="http://aaa/weblink400/1/backoffice.app?noplugin=1"/>
</propertyfile>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我在尝试使用 Maven pom.xml 文件中的 antrun 插件更改 属性 文件内容时遇到以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (ant-create-properties
-file-content) on project SROTest: An Ant BuildException has occured: Problem: failed to create task or ty
pe propertyfile
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.PropertyFile was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME\lib
[ERROR] -the IDE Ant configuration dialogs
[ERROR]
[ERROR] Do not panic, this is a common problem.
[ERROR] The commonest cause is a missing JAR.
[ERROR]
[ERROR] This is not a bug; it is a configuration problem
[ERROR]
[ERROR] -> [Help 1]
这是我的 pom.xml 文件:
<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>com.mycompany</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<suiteFile></suiteFile>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>ant-create-properties-file-content</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<propertyfile file="test.properties">
<entry key="browser" value="chrome"/>
<entry key="run_on_grid" value="true"/>
<entry key="hub_address" value="selenium-hub.service.mycompany.mgmt"/>
<entry key="take_screenshots_on" value="true"/>
<entry key="highlight_on" value="true"/>
<entry key="recording_video_on" value="false"/>
<entry key="run_with_KLB" value="false"/>
<entry key="sut_url" value="http://aaa/weblink400/1/backoffice.app?noplugin=1"/>
</propertyfile>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
此脚本的目标是更改属性文件内容,当使用 ant build.xml 文件和 ant 命令(cmd 命令)执行它时,它按预期工作,但当尝试使用 maven 命令执行它时。我得到了上面显示的失败。
将依赖项作为 <dependency>
放在 <plugin>
下。
这应该是这样的:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>optional</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>ant-create-properties-file-content</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<propertyfile file="test.properties">
<entry key="browser" value="chrome"/>
<entry key="run_on_grid" value="true"/>
<entry key="hub_address" value="selenium-hub.service.mycompany.mgmt"/>
<entry key="take_screenshots_on" value="true"/>
<entry key="highlight_on" value="true"/>
<entry key="recording_video_on" value="false"/>
<entry key="run_with_KLB" value="false"/>
<entry key="sut_url" value="http://aaa/weblink400/1/backoffice.app?noplugin=1"/>
</propertyfile>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>