gpt4 book ai didi

java - 获取 Eclipse 快照依赖的来源

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:18:35 25 4
gpt4 key购买 nike

有件事让我很烦恼...在一个有很多依赖的大项目上,其中一些在 Maven2 中设置为 SNAPSHOT。

问题是,如果不加载项目或将依赖项修复到最新版本,我似乎无法通过 Eclipse 获取源代码。为了调试,真是烦死我了……

编辑

这是我在 eclipse maven 控制台中得到的:

26/08/10 11:31:46 CEST: Downloading http://repo-maven/archiva/repository/snapshots/com/blabla/1.1-SNAPSHOT/blabla-1.1-20100824.213711-80-javadoc.jar
26/08/10 11:31:47 CEST: Could not download sources for com.blabla:blabla:1.1-20100824.213711-80

在 archiva 上,我可以看到我想在 eclipse 中检索的已部署内容...

Repository   snapshots
Group ID com.blabla
Artifact ID blabla
Version 1.1-20100824.213711-80
Packaging jar
Parent com.blabla bla 1.1-SNAPSHOT (View)
Other Versions 1.1-20100824.213535-79

我可以使用我的浏览器下载这个工件的源代码,但不能在 Eclipse 中下载...有什么想法吗?

最佳答案

The matter is that it seems I can't get the sources through Eclipse without loading the project or fixing the dependency to the last release. For debugging, it's really annoying me...

好吧,这些模块可能不会将源 JAR 作为“常规”构建过程的一部分(即在发布之外)发布。如果这些模块在你的控制之下(这是我的理解),配置 Maven Source Plugin为它们生成源 JAR 并将它们部署到您的公司仓库中应该可以解决问题。来自Usage页:

Installing the sources along with your artifact

There are two ways to do this. You can either bind this plugin to a phase or you can add it to a profile. The goals source:jar-no-fork and source:test-jar-no-fork are preferred for binding the goal to the build lifecycle.

Installing the sources using a phase binding

Here is how you would configure the plugin in your pom.xml to run automatically during the verify phase:

<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>

We are using the verify phase here because it is the phase that comes before the install phase, thus making sure that the sources jar has been created before the install takes place.

Installing the sources using a profile

If you want to install a jar of your sources along with your artifact during the release process, you can add this to your pom.xml file:

<project>
...
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
...
</project>

使用配置文件可能是个好主意,这样构建源 JAR 将仅由在 CI 服务器级别而非开发人员机器上运行的构建完成。

关于java - 获取 Eclipse 快照依赖的来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3568042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com