Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven扩展在生成期间未处于活动状态_Java_Maven_Build_Maven Extension - Fatal编程技术网

Java Maven扩展在生成期间未处于活动状态

Java Maven扩展在生成期间未处于活动状态,java,maven,build,maven-extension,Java,Maven,Build,Maven Extension,我正在尝试创建一个新的maven扩展。但是,当我使用${maven.projectBasedir}/.mvn/extensions.xml中声明的扩展运行maven构建时,扩展的ExecutionListener将不会侦听 我的扩展名的pom.xml是: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:sc

我正在尝试创建一个新的maven扩展。但是,当我使用
${maven.projectBasedir}/.mvn/extensions.xml
中声明的扩展运行maven构建时,扩展的
ExecutionListener
将不会侦听

我的扩展名的
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>org.example</groupId>
    <artifactId>test-extension</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>3.6.0</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-component-annotations</artifactId>
            <version>1.7.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-component-metadata</artifactId>
                <version>1.7.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-metadata</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
生成的
components.xml
为:

<?xml version="1.0" encoding="UTF-8"?>
<component-set>
  <components>
    <component>
      <role>org.apache.maven.execution.ExecutionListener</role>
      <role-hint>default</role-hint>
      <implementation>org.example.testextension.Foo</implementation>
      <description />
      <isolated-realm>false</isolated-realm>
    </component>
  </components>
</component-set>
<extension>
    <exportedPackages>
        <exportedPackage>org.example.testextension</exportedPackage>
    </exportedPackages>
    <exportedArtifacts>
        <exportedArtifact>org.apache.maven:maven-core</exportedArtifact>
        <exportedArtifact>org.codehaus.plexus:plexus-component-annotations</exportedArtifact>
    </exportedArtifacts>
</extension>
我尝试在另一个项目中使用
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>org.example</groupId>
    <artifactId>maven-extension-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</project>
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
    <extension>
        <groupId>org.example</groupId>
        <artifactId>test-extension</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </extension>
</extensions>
当运行这个构建时,我可以看到扩展正在尝试从maven repo下载。但是扩展没有发生任何其他事情

我希望看到构建失败,因为在执行侦听器中强制出现各种异常。但是构建成功了

在构建中使用扩展的执行侦听器时,我缺少了什么

我正在使用maven:

Maven home: C:\Program Files\apache\apache-maven-3.6.2\bin\..
Java version: 1.8.0_161, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_161\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
编辑:
问题还报告给Maven问题跟踪者:

首先,您能解释一下分机应该做什么吗?此外,你说的下载是什么意思?您是否收到错误/警告?您可以在GitHub上创建一个示例项目吗?@khmarbaise,如问题中的代码所示,扩展应侦听通过
ExecutionListener
接口提供的不同事件。在这个mcve上没有什么要说的了,我也看到了同样的事情。我在Apache tracker.HI中对这个问题进行了评论,在尝试使用pom操作ext Maven扩展()时,我在.mvn/extensions.xml中遇到了同样的问题。当将jar放入${MAVEN_HOME}/lib/ext中时,它工作得很好,但当使用extensions.xml时,它不工作。首先,您能解释一下扩展应该做什么吗?此外,你说的下载是什么意思?您是否收到错误/警告?您可以在GitHub上创建一个示例项目吗?@khmarbaise,如问题中的代码所示,扩展应侦听通过
ExecutionListener
接口提供的不同事件。在这个mcve上没有什么要说的了,我也看到了同样的事情。我在Apache tracker.HI中对这个问题进行了评论,在尝试使用pom操作ext Maven扩展()时,我在.mvn/extensions.xml中遇到了同样的问题。将jar放入${MAVEN_HOME}/lib/ext中时,它工作良好,但在使用extensions.xml时,它不工作。
Maven home: C:\Program Files\apache\apache-maven-3.6.2\bin\..
Java version: 1.8.0_161, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_161\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"