Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

eclipse - Unable to package plugin

I have created an eclipse plugin, with the following Manifest file:

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,
 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

Unfortunately, including the relevant jars as external jars has not allowed me to create the plugin succesfully so I've tried instead (following the recommendation present on vogella) to export the target platform and create a parent pom and inside it place my plugin project and another project that uses the target platform to manage the dependencies: The parent 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>

The target platform project:

<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>

The plugin pom is below:

<?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>

The target-platform.target file is as below:

<?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 [email protected]/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"/>
         .....

However, when I run mvn clean package I get the following exception:

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)

This is because one of the dependencies i.e. org.apache.log4j_1.2.17.2019-11-22 is actually a ddirectory with a log4j-lib plugin inside. This works fine when running the project in the IDE but I can't figure out how to resolve this correctly. Any help would be appreciated!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So the actual solution was to create a new plugin using existing jar archives option. Add that plugin as a dependency to my plugin and add that to the parent pom.xml in the modules section. Required some tinkering with dependencies but adding the resulting built jar files to the dropins folder seemed to have worked for now.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...