微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法打包插件

如何解决无法打包插件

我创建了一个 Eclipse 插件,其中包含以下清单文件

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Commitlinking
Bundle-SymbolicName: com.polarion.commitlinking;singleton:=true
Bundle-Version: 1.0.0.202101092309
Bundle-Classpath: com.polarion.commitlinking_1.0.0.202101092309.jar
Bundle-Activator: com.polarion.commitlinking.Activator
Bundle-vendor: POLARION
Require-Bundle: javax.inject,org.eclipse.osgi,org.eclipse.jface,org.eclipse.e4.ui.model.workbench,org.eclipse.e4.ui.di,org.eclipse.e4.ui.services,org.eclipse.e4.core.di.annotations,org.eclipse.core.runtime,org.eclipse.e4.core.di,org.eclipse.e4.core.contexts;bundle-version="1.8.400",org.eclipse.e4.ui.workbench,org.eclipse.core.commands,org.eclipse.ui.workbench,org.eclipse.ui,com.polarion.alm.ws.client
Bundle-requiredExecutionEnvironment: JavaSE-15
Bundle-ActivationPolicy: lazy
Import-Package: javax.annotation;version="1.2.0",javax.inject;version="1.0.0",org.eclipse.core.expressions,org.eclipse.core.runtime;version="3.5.0",org.eclipse.e4.core.commands,org.eclipse.e4.core.di.extensions;version="0.16.0",org.eclipse.e4.core.services.events,org.eclipse.e4.ui.dialogs,org.eclipse.e4.ui.workbench.modeling,org.eclipse.jface.text,org.eclipse.ui.commands,org.eclipse.ui.menus,org.eclipse.ui.plugin,org.osgi.service.event;version="1.4.0"
Automatic-Module-Name: com.polarion.commitlinking

不幸的是,将相关的 jars 包括为外部 jars 并不允许我成功创建插件,所以我尝试改为(按照 vogella 上的建议)导出目标平台并创建一个父 pom 并在其中放置我的插件项目和另一个使用目标平台管理依赖项的项目: 父pom:

<?xml version="1.0" encoding="UTF-8"?>
<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.packtpub.e4</groupId>
<artifactId>com.packtpub.e4.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
    <tycho.version>2.1.0</tycho.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <eclipse-repo.url>http://download.eclipse.org/releases/latest</eclipse-repo.url>
</properties>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-director-plugin</artifactId>
                <version>${tycho.version}</version>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>${tycho.version}</version>
            <extensions>true</extensions>
        </plugin>
        <!--Enable the replacement of the SNAPSHOT version in the final product 
            configuration -->
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-packaging-plugin</artifactId>
            <version>${tycho.version}</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <id>package-feature</id>
                    <configuration>
                        <finalName>${project.artifactId}_${unqualifiedVersion}.${buildQualifier}</finalName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>${tycho.version}</version>
            <configuration>
                <target>
                    <artifact>
                        <groupId>com.vogella.tycho</groupId>
                        <artifactId>target-platform</artifactId>
                        <version>1.0.0-SNAPSHOT</version>
                    </artifact>
                </target>
                <environments>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86_64</arch>
                    </environment>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86_64</arch>
                    </environment>
                    <environment>
                        <os>macosx</os>
                        <ws>cocoa</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
            </configuration>
        </plugin>
    </plugins>
</build>
<modules>
      <module>target-platform</module>
      <module>com.polarion.commitlinking</module>
</modules>

目标平台项目:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.packtpub.e4</groupId>
        <artifactId>com.packtpub.e4.parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <groupId>com.vogella.tycho</groupId>
    <artifactId>target-platform</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>eclipse-target-deFinition</packaging>
    <name>target-platform</name>
</project>

插件pom如下:

<?xml version="1.0" encoding="UTF-8"?>
<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.polarion</groupId>
    <artifactId>com.polarion.commitlinking</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>eclipse-plugin</packaging>
    <parent>
        <groupId>com.packtpub.e4</groupId>
        <artifactId>com.packtpub.e4.parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
</project>

target-platform.target 文件如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="Polarion plugin development">
    <locations>
        <location path="/home/bilal/eclipse/java-2020-092/eclipse/" type="Profile"/>
        <location path="/opt/polarion/polarion/" type="Directory"/>
        <location path="/home/bilal/Programs/eclipse-installer/plugins/" type="Directory"/>
    </locations>
    <environment>
        <arch>x86_64</arch>
        <os>linux</os>
        <ws>gtk</ws>
        <nl>en_US</nl>
    </environment>
    <launcherArgs>
        <vmArgs>-Declipse.p2.max.threads=10 -Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/-&gt;http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ -Dosgi.requiredJavaVersion=11 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYstem -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitinit=true -xms256m -Xmx2048m --add-modules=ALL-SYstem</vmArgs>
    </launcherArgs>
    <includeBundles>
        <plugin id="ch.qos.logback.classic"/>
         .....

但是,当我运行 mvn clean package 时,出现以下异常:

Internal error: org.eclipse.tycho.repository.local.MirroringArtifactProvider$MirroringFailedException: Could not mirror artifact osgi.bundle,org.apache.log4j,1.2.17.2019-11-22 into the local Maven repository.See log output for details. /opt/polarion/polarion/plugins/org.apache.log4j_1.2.17.2019-11-22 (Is a directory)

这是因为其中一个依赖项,即 org.apache.log4j_1.2.17.2019-11-22 实际上是一个 ddirectory,里面有一个 log4j-lib 插件。这在 IDE 中运行项目时工作正常,但我不知道如何正确解决这个问题。任何帮助将不胜感激!

解决方法

所以实际的解决方案是使用现有的 jar 档案选项创建一个新插件。将该插件添加为我的插件的依赖项,并将其添加到模块部分的 parent pom.xml。需要对依赖项进行一些修补,但将生成的 jar 文件添加到 dropins 文件夹似乎现在已经起作用了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?