java - Maven 中的 "Project build error: Unknown packaging: eclipse-plugin"

标签 java eclipse maven eclipse-plugin tycho

我有一个 Maven 父级,其中我为插件定义了 1 个模块。

父 pom 如下所示:

<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.angle</groupId>
<artifactId>angle-eclipse</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>

<modules>
    <module>../com.angle.ui</module>
</modules>

<properties>
    <java.version>1.8</java.version>
    <tycho-version>1.0.0</tycho-version>
    <oxygen-repo.url>http://download.eclipse.org/releases/oxygen</oxygen-repo.url>
    <goal.preset>clean install</goal.preset>
</properties>

<repositories>
    <repository>
        <id>oxygen</id>
        <layout>p2</layout>
        <url>${oxygen-repo.url}</url>
    </repository>
</repositories>

<build>
    <!-- <defaultGoal>${goal.preset}</defaultGoal> -->
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho-version}</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

该模块是一个插件,我已将其性质转换为 Maven。

模块的 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>
<name>com.angle.ui</name>
<description>UI part of the plug-in</description>

<parent>
    <groupId>com.angle</groupId>
    <artifactId>angle-eclipse</artifactId>
    <version>1.0.0</version>
    <relativePath>../angle-eclipse</relativePath>
</parent>

<artifactId>com.angle.ui</artifactId>   
<packaging>eclipse-plugin</packaging>

现在,即使我已将 tycho-maven-plugin 添加为构建插件,它也会给我错误:项目构建错误:未知打包:eclipse-plugin 并且我无法构建 Maven 项目。

没有其他错误。

我也搜索了其他帖子,但他们给出的唯一解决方案是将 tycho-maven-plugin 作为构建插件包含在父 pom 中,而这种方法并不能解决我的问题。

请帮我解决这个问题。

最佳答案

我能够通过更改父项 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.angle</groupId>
<artifactId>angle-eclipse</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>

<modules>
    <module>../com.angle.ui</module>
</modules>

<properties>
    <java.version>1.8</java.version>
    <tycho-version>1.0.0</tycho-version>
    <oxygen-repo.url>http://download.eclipse.org/releases/oxygen</oxygen-repo.url>
    <goal.preset>clean install</goal.preset>
</properties>

<repositories>
    <repository>
        <id>oxygen</id>
        <layout>p2</layout>
        <url>${oxygen-repo.url}</url>
    </repository>
</repositories>

<build>
    <!-- <defaultGoal>${goal.preset}</defaultGoal> -->
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>${tycho-version}</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

关键的区别在于<extension>需要低于project/build/plugins而不是project/build/pluginManagement/pluginsManaged plugins除非在其他地方引用,否则不会有效;因此,构建扩展未启用,eclipse-plugin包装未注册。

关于java - Maven 中的 "Project build error: Unknown packaging: eclipse-plugin",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48181775/

相关文章:

java - 如何防止 9-Patch 文件的中心被拉伸(stretch)?

java - 当我们可以创建 String s = ("abc"时,需要什么 String s = new String "abc")

java - LinkedList深拷贝java

eclipse - 最佳实践 : sharing files between projects in Eclipse

java - 调试Grails时速度慢

spring - 带有Gradle的Apache Tiles在 Spring 启动中不起作用

java - Maven javadoc 插件 3.1.0 不生成聚合 javadoc

maven - 删除从 spring-boot-starter-parent 继承的额外依赖项

java - 多线程 Hello World

java - Eclipse 生成 equals 方法 : if ( obj == null ) vs. if ( null == obj )