为啥 IvyDE 可以使用 scala-library 的源而不使用 scalaz-core_2.10.0-RC3-7.0.0-M5 的源?
Posted
技术标签:
【中文标题】为啥 IvyDE 可以使用 scala-library 的源而不使用 scalaz-core_2.10.0-RC3-7.0.0-M5 的源?【英文标题】:Why can IvyDE use the source for scala-library but not the source for scalaz-core_2.10.0-RC3-7.0.0-M5?为什么 IvyDE 可以使用 scala-library 的源而不使用 scalaz-core_2.10.0-RC3-7.0.0-M5 的源? 【发布时间】:2012-11-26 21:04:59 【问题描述】:我将 IvyDE 与 Eclipse Indigo 一起使用。我有一个看起来像这样的 ivy.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="com.restphone" module="javasignatureparser_2.10" revision="0.3-SNAPSHOT" status="integration" publication="20121208180225">
<description>
JavaSignatureParser
</description>
</info>
<configurations>
<conf name="compile" visibility="public" description=""/>
<conf name="runtime" visibility="public" description="" extends="compile"/>
<conf name="test" visibility="public" description="" extends="runtime"/>
<conf name="provided" visibility="public" description=""/>
<conf name="optional" visibility="public" description=""/>
<conf name="sources" visibility="public" description=""/>
<conf name="docs" visibility="public" description=""/>
<conf name="pom" visibility="public" description=""/>
</configurations>
<dependencies defaultconfmapping="*->default,sources" >
<dependency org="org.scalaz" name="scalaz-core_2.10.0-RC3" rev="7.0.0-M5" conf="compile->default(compile);sources->default(compile)"/>
</dependencies>
</ivy-module>
IvyIDE 容器有 scala-library 的源附件(传递依赖,没有在 ivy.xml 代码中列出),但没有 scalaz-core 的源附件。
如果我查看本地 ivy 缓存(容器有文件的地方),我会看到:
C:\Users\james\.ivy2\cache\org.scalaz\scalaz-core_2.10.0-RC3
bundles
scalaz-core_2.10.0-RC3-7.0.0-M5.jar
sources
scalaz-core_2.10.0-RC3-7.0.0-M5-sources.jar
知道为什么 IvyIDE 无法弄清楚如何使用 scalaz-core_2.10.0-RC3-7.0.0-M5-sources.jar 吗?
/cygdrive/C/Users/james/.ivy2/cache/org.scalaz/scalaz-core_2.10.0-RC3/ivy-7.0.0-M5.xml 中有一个 ivy 配置文件,说明了artifact 是一个“捆绑包”——这有关系吗?
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="org.scalaz"
module="scalaz-core_2.10.0-RC3"
revision="7.0.0-M5"
status="release"
publication="20121123051347"
>
<license name="BSD-style" url="http://www.opensource.org/licenses/bsd-license.php" />
<description homepage="http://scalaz.org">
scalaz-core
</description>
</info>
<configurations>
<conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
<conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
<conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
<conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
<conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
<conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends="runtime"/>
<conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository."/>
<conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
<conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
<conf name="optional" visibility="public" description="contains all optional dependencies"/>
</configurations>
<publications>
<artifact name="scalaz-core_2.10.0-RC3" type="bundle" ext="jar" conf="master"/>
</publications>
<dependencies>
<dependency org="org.scala-lang" name="scala-library" rev="2.10.0-RC3" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
</dependencies>
</ivy-module>
更新:事情变得有点奇怪。如果我删除该 scalaz-core_2.10.0-RC3/ivy-7.0.0-M5.xml 文件,然后更改 ivy.xml 中的一行,该文件将再次下载 - 它不一样。有时,我会在文件中获得更多行!像这样:
<publications>
<artifact name="scalaz-core_2.10.0-RC3" type="bundle" ext="jar" conf="master"/>
<artifact name="scalaz-core_2.10.0-RC3" type="source" ext="jar" conf="sources" m:classifier="sources"/>
<artifact name="scalaz-core_2.10.0-RC3" type="javadoc" ext="jar" conf="javadoc" m:classifier="javadoc"/>
</publications>
【问题讨论】:
【参考方案1】:类型相关,IvyDE 使用 'sources type' 确定源是否存在。
在“源类型”中,在 IvyDE 托管库的选项卡 Source/Javadoc 中。默认值为“源”。
您在已解析工件的 ivy.xml 中显示的内容表明类型是捆绑包,不会被视为源工件。
但是,我尝试使用非常默认的配置(我刚刚将 Eclipse 和 IvyDE 安装到一个空项目)以及 scalaz-core 的已解析 ivy 文件来解决自己:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="org.scalaz"
module="scalaz-core_2.10.0-RC3"
revision="7.0.0-M5"
status="release"
publication="20121123141347"
>
<license name="BSD-style" url="http://www.opensource.org/licenses/bsd-license.php" />
<description homepage="http://scalaz.org">
scalaz-core
</description>
</info>
<publications>
<artifact name="scalaz-core_2.10.0-RC3" type="bundle" ext="jar" conf="master"/>
<artifact name="scalaz-core_2.10.0-RC3" type="source" ext="jar" conf="sources" m:classifier="sources"/>
<artifact name="scalaz-core_2.10.0-RC3" type="javadoc" ext="jar" conf="javadoc" m:classifier="javadoc"/>
</publications>
<dependencies>
<dependency org="org.scala-lang" name="scala-library" rev="2.10.0-RC3" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
</dependencies>
为了清楚起见,我删除了配置部分。
你确定你是从 maven2 仓库下载的吗:
http://repo1.maven.org/maven2/
也许他们在过去 10 小时内更改了它。
如果我是你,我会尝试将捆绑包添加到“源类型”。不过不确定后果。
【讨论】:
这是有用的信息,谢谢。不幸的是,我认为我的问题比这更奇怪。事实证明,有时,从我自己的 Nexus 安装(Central 的缓存)下载,我最终会得到一个在出版物中只有一行的已解析文件。 (这与 scalaz 无关——它只发生在 asm 4.1 中)。然后,如果我从本地文件系统中删除它,更改 ivy.xml 中的一行(强制重新加载),下次我在出版物中获得三行。当然是从同一个存储库下载 - 三十秒后。以上是关于为啥 IvyDE 可以使用 scala-library 的源而不使用 scalaz-core_2.10.0-RC3-7.0.0-M5 的源?的主要内容,如果未能解决你的问题,请参考以下文章
ivy或ivyDE能否在Eclipse中自动将相关jar添加到JAVA构建路径库中?
无法使用 Eclipse 中的 IvyDE 插件从常春藤缓存中删除过时的工件