【问题标题】:"Project build error: Unknown packaging: eclipse-plugin" in MavenMaven 中的“项目构建错误:未知打包:eclipse-plugin”
【发布时间】:2018-06-19 06:57:40
【问题描述】:

我有一个 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 中,这种方法并不能解决我的问题。

请帮我解决这个问题。

【问题讨论】:

  • @Stultuske 它不是重复的。正如我的问题中提到的,我已经尝试过这种方法,但它不起作用。
  • 你尝试了多少这种方法?
  • 我试过添加tycho-maven-plugin的插件。
  • 建议的“方法”远不止于此。如果您只实施了建议解决方案的 25%,那么它确实有可能不起作用

标签: java eclipse maven eclipse-plugin tycho


【解决方案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.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>

关键区别在于&lt;extension&gt; 需要低于project/build/plugins 而不是project/build/pluginManagement/pluginsManaged plugins 除非在别处引用,否则无效;因此,构建扩展未启用,eclipse-plugin 包装未注册。

【讨论】:

  • 但是通过这种方法,我得到了以下错误:Plugin execution not covered by lifecycle configuration: org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile (execution: default-compile, phase: compile) 在使用快速修复这个问题时,我得到了上面的代码并且所有的错误都得到了解决。
  • 是的,但是Plugin execution not covered by lifecycle configuration 与问题所在的Project build error: Unknown packaging: eclipse-plugin 错误无关。因此,我删除了与您的原始问题相关的解决方案部分。但是当然,您仍然应该添加生命周期映射如果您正在使用 m2e。
  • 好的。我现在知道了。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-22
  • 1970-01-01
  • 2012-06-16
  • 2015-03-15
  • 1970-01-01
  • 2015-08-01
  • 1970-01-01
相关资源
最近更新 更多