简体   繁体   中英

How to handle Dependencies in Eclipse Plugin Project using Tycho

I'm writing an eclipse plugin and I'd like to manage it using Maven, specifically dependencies.

Here is my pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.plugin</groupId>
    <artifactId>SomePlugin</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>eclipse-plugin</packaging>

    <properties>
        <tycho.version>0.24.0</tycho.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>

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

    <repositories>
        <repository>
            <id>luna</id>
            <layout>p2</layout>
            <url>http://download.eclipse.org/releases/luna</url>
        </repository>
    </repositories>

</project>

I can successfully build this project, however Junit is not visible in my project, I'm not able to call any classes or method from Junit. So it seems I'm not properly using dependencies . Any idea how I can use dependencies? Junit is just an example, no dependency is available to me after a successful build.

I'm a noob to plugins and Maven so any help or guidance would be much appreciated.

You can create a p2 repository from a location of your own filled with jars/plugins/features (also put there jUnit) and then just add that repository to your pom.xml; the external dependency is not a good idea I think, I would recommend using a cached local repository. How to create p2 repository : http://wiki.eclipse.org/Equinox/p2/Publisher#Features_And_Bundles_Publisher_Application . Also, when building your Eclipse RCP product, use a custom target platform and also dump in there Eclispe SDK, JUnit+others jars, etc (just google Eclipe target platform)

A very late answer. For those who come on this now, there is the Orbit Eclipse repository which contain a lot of libraries useable with Tycho builds. Junit is one of these.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM