Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将maven依赖项作为类路径库添加到Eclipse插件运行时?_Maven_Eclipse Plugin_Dependencies_Classpath_Tycho - Fatal编程技术网

如何将maven依赖项作为类路径库添加到Eclipse插件运行时?

如何将maven依赖项作为类路径库添加到Eclipse插件运行时?,maven,eclipse-plugin,dependencies,classpath,tycho,Maven,Eclipse Plugin,Dependencies,Classpath,Tycho,我正在开发一个eclipse插件,并正在将其转换为Maven项目。我使用了“Configure->Convert to Maven project”选项,并编写了pom.xml文件,其中包含适当的依赖项以及对tycho和Maven插件的引用 <properties> <tycho.version>0.23.0</tycho.version> <project.build.sourceEncoding>UTF-8</projec

我正在开发一个eclipse插件,并正在将其转换为Maven项目。我使用了“Configure->Convert to Maven project”选项,并编写了pom.xml文件,其中包含适当的依赖项以及对tycho和Maven插件的引用

<properties>
    <tycho.version>0.23.0</tycho.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-repository-plugin</artifactId>
                <version>${tycho.version}</version>
                <configuration>
                    <includeAllDependencies>true</includeAllDependencies>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <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>target-platform-configuration</artifactId>
            <version>${tycho.version}</version>
            <configuration>
                <target>
                    <artifact>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <version>${project.version}</version>
                    </artifact>
                </target>
                <environments>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86_64</arch>
                    </environment>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86</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>
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

0.23.0
UTF-8
src
org.eclipse.tycho
tycho-p2-repository-plugin
${tycho.version}
真的
org.eclipse.tycho
tycho maven插件
${tycho.version}
真的
org.eclipse.tycho
目标平台配置
${tycho.version}
${project.groupId}
${project.artifactId}
${project.version}
linux
gtk
x86
linux
gtk
x86_64
win32
win32
x86
win32
win32
x86_64
马科斯
热可可
x86_64
真的
org.apache.maven.plugins
maven编译器插件
1.6
1.6
然而,maven依赖库并不会自动添加到项目的类路径中,甚至当我尝试将它们添加到.classpath文件时,例如。
(配置了M2\u REPO classpath变量)我仍然收到清单文件中缺少类的异常


在eclipse中是否可以在项目根目录之外设置类路径?如果可以,是否可以自动将maven依赖项库添加到项目的类路径?

eclipse插件仅将osgi捆绑包和插件作为其依赖项。如果您将依赖项作为普通jar提供,则不需要。清单文件将获取eclipse home的p2存储库、目标定义文件或eclipse站点中提供的插件和捆绑包。因此,我建议您将maven依赖项jar转换为osgi捆绑包或插件,并将其作为依赖项添加到eclipse插件中,这样您就不会在maven构建过程中出现任何错误。

eclipse插件只将osgi捆绑包和插件作为其依赖项。如果您将依赖项作为普通jar提供,则不需要。清单文件将获取eclipse home的p2存储库、目标定义文件或eclipse站点中提供的插件和捆绑包。因此,我建议您将maven依赖项jar转换为osgi捆绑包或插件,并将其作为一个依赖项添加到eclipse插件中,以便在maven构建期间不会出现任何错误