首页 > 解决方案 > Tycho 复制依赖不包括插件依赖

问题描述

对于我的第谷反应器中的一个插件,我想在名为“lib/”的文件夹中复制一个“纯 maven”依赖项及其传递依赖项。

目前,如果我使用copy-dependencies来自 的目标maven-dependency-plugin,我的依赖项会被正确复制,但由 tycho 解析的“插件依赖项”也会被复制,我不想要这些。

有什么建议可以实现这个目标吗?我目前正在使用以下代码片段

<dependencies>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>
</dependencies> 

<build>
    <plugins>
        <plugin>
            <groupId>${maven.groupid}</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>process-resources</phase> 
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer> 
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

欢迎任何建议。

标签: maventycho

解决方案


Eclipse 论坛上的讨论之后,我们似乎可以告诉 maven 仅使用和标记的组合包含来自当前pom.xml文件的依赖项。excludeScopeincludeScope

这个更新的 XML 片段按预期完成了工作

<dependencies>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>
</dependencies> 

<build>
    <plugins>
        <plugin>
            <groupId>${maven.groupid}</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>process-resources</phase> 
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer> 
                        <!-- The lines below are aimed at telling maven NOT TO COPY tycho dependencies. Do not remove those! -->
                        <!-- See: https://dev.eclipse.org/mhonarc/lists/tycho-user/msg05080.html -->
                        <excludeScope>system</excludeScope>
                        <includeScope>runtime</includeScope>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

推荐阅读