获得一个罐子连同其来源和javadoc [英] Getting a jar along with its sources and javadoc
本文介绍了获得一个罐子连同其来源和javadoc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
随着的ivy.xml
如下:
<依赖有机=com.amazonawsNAME =AWS-java的SDKREV =1.4.5 >
<工件名称=AWS-java的SDK分机=罐子/>
< /依赖性>
它下载 AWS-java的SDK-1.4.5.jar
,这是AWS SDK,即的类。
这很好,但我也想获得的Javadoc和源代码。
以下建议从常春藤:撷取的Javadoc和源的我把下面的的ivy.xml
<配置>
<的conf名称=默认/>
<的conf名=编译知名度=公共/>
<的conf名=来源知名度=公共/>
<的conf名=javadoc的知名度=公共/>
< /配置>
<依赖有机=com.amazonawsNAME =AWS-java的SDK
REV =1.4.5传递=真
CONF =javadoc->的javadoc;来源 - >来源;编制─>默认/>
它下载 AWS-java的SDK-1.4.5.jar
的只有的,这是的的Javadoc 的(没有阶级或源文件)。
更新:从文件片段,可能是有用
的build.xml
<。项目名称=AWS项目BASEDIR =的xmlns:常春藤=的antlib:org.apache.ivy.ant>
<目标名称=建造取决于=干净,配置,常春藤设置,artifactory的-检索>
常春藤-config.xml中
<项目名称=artifactory的自举的xmlns:AC =HTTP://ant-contrib.sourceforge。网的xmlns:常春藤=的antlib:org.apache.ivy.ant默认值=配置 - 常春藤设置>
<目标名称=配置 - 常春藤设置,除非=skip.artifact.retrieve>
< echoproperties preFIX =常青藤/>
<! - 更改为指向分公司artifactory的 - >
<属性名=artifactory.branch值=20.0/>
<! - 更改为你构建的SRCROOT - >
<属性名=build.srcroot值=$ {bootstrap.basedir}/>
<! - 配置IVY设置 - >
<常春藤:设置url="https://artifactory.mycompany.com/artifactory/simple/bootstrap/${artifactory.branch}/ivysetting-artifactory.xml" ID =artifactory.ivy.settings主机=artifactory.mycompany.com的境界=Artifactory的境界用户名=$ {artifactory.user}passwd文件=$ {artifactory.password}/>
< /目标和GT;
<目标名称=artifactory的-检索,除非=skip.artifact.retrieve>
<属性名=download.dir值=$ {bootstrap.basedir} / EXTLIB/>
<删除DIR =$ {download.dir}/>
< MKDIR DIR =$ {download.dir}/>
<常春藤:解决settingsRef =artifactory.ivy.settings文件=$ {ivy.file}/>
<常春藤:cachefileset settingsRef =artifactory.ivy.settingsSETID =latest.downloads/>
<回声消息=文物的网址为:$ {download.dir}/>
<复制压扁=真todir =$ {download.dir}>
<文件集REFID =latest.downloads/>
< /复制和GT;
<文件集ID =ivy.filesetDIR =$ {download.dir}>
<包括姓名=*罐子。/>
< /文件集>
<属性名=ivy.downloads.filesetREFID =ivy.fileset/>
<! - 构建classpath中的下载// - >
&其中;路径的id =ivy.classpath>
<文件集DIR =$ {download.dir}>
<包括姓名=*罐子。/>
< /文件集>
< /路径>
<属性名=ivy.downloads.classpathREFID =ivy.classpath/>
<回声消息=ivy.downloads.classpath = $ {ivy.downloads.classpath}/>
<回声消息=文物的网址为:$ {download.dir}/>
< echo消息= /&GT他们可以使用文件集REFID ivy.downloads.fileset或ivy.downloads.classpath参考;
< /目标和GT;
解决方案
示例
├──构建
│└──LIB
│├──编译
││├──AWS-java的SDK-1.4.5.jar
││├──commons- codeC-1.3.jar
││├──共享记录-1.1.1.jar
││├──HttpClient的-4.1.jar
││├──的HttpCore-4.1.jar
││├──杰克逊核心ASL-1.8.9.jar
││└──杰克逊映射器-ASL-1.8.9.jar
│├──的javadoc
││└──AWS-java的SDK-1.4.5-javadoc.jar
│└──来源
│└──AWS-java的SDK-1.4.5-sources.jar
├──build.xml文件
└──的ivy.xml
的build.xml
<项目名称=演示默认为建的xmlns:常春藤=的antlib:org.apache.ivy.ant>
<目标名称=构建描述=编译code>
<常春藤:检索模式=构建/ lib中/ [设置] / [神器] - [修改]( - [分类])[转]。/>
< /目标和GT;
<目标名称=干净的描述=此外常春藤清除缓存>
<删除DIR =打造/>
<常春藤:cleancache />
< /目标和GT;
< /项目>
请注意:
- 在常青藤检索任务使用一个特殊的图案把文件放入根据配置不同的目录中。
- 的分类属性是可选的,因此括号括起来。
的ivy.xml
<常青藤模块版本=2.0>
<信息组织=com.myspotontheweb模块=演示/>
<配置>
<的conf名=编译描述=需要编译应用程序/>
<的conf名=来源描述=来源$ C $ C/>
<的conf名=javadoc的说明=的Javadoc/>
< /配置>
<依赖>
<依赖有机=com.amazonawsNAME =AWS-java的SDKREV =1.4.5的conf =之前编制>默认;来源; javadoc的/>
< /依赖性>
< /常春藤模块>
请注意:
- 在配置映射是由3部分组成:之前编制>默认,源,javadoc的 。
更新 - 第二个例子
替代目录布局这个时候:
├──构建
│├──DOC
││└──AWS-java的SDK-1.4.5-javadoc.jar
│├──LIB
││├──AWS-java的SDK-1.4.5.jar
││├──commons- codeC-1.3.jar
││├──共享记录-1.1.1.jar
││├──HttpClient的-4.1.jar
││├──的HttpCore-4.1.jar
││├──杰克逊核心ASL-1.8.9.jar
││└──杰克逊映射器-ASL-1.8.9.jar
│└──SRC
│└──AWS-java的SDK-1.4.5-sources.jar
├──build.xml文件
└──的ivy.xml
的build.xml
<项目名称=演示默认为建的xmlns:常春藤=的antlib:org.apache.ivy.ant>
<目标名称=构建描述=编译code>
<常春藤:检索模式=构建/ lib中/ [神器] - [修改] [转]。CONF =编译/>
<常春藤:检索模式=建立/ src目录/ [神器] - [修改]( - [分类])[转]。CONF =来源/>
<常春藤:检索模式=建设/ DOC / [神器] - [修改]( - [分类])[转]。CONF =javadoc的/>
< /目标和GT;
<目标名称=干净的描述=此外常春藤清除缓存>
<删除DIR =打造/>
<常春藤:cleancache />
< /目标和GT;
< /项目>
注:
- 在观察了每个检索任务的自定义放置在特定目录中的文件。配置用于确定所使用的文件。配置是一个分组机制。
- 在重新审核在ivy文件中的依赖的配置映射。这是神奇的,它确定如何常春藤分类下载的文件。
- 有关配置映射的详细信息,请参见:<一href="http://stackoverflow.com/questions/7104364/how-are-maven-scopes-mapped-to-ivy-configurations-by-ivy/7116577#7116577">How被行家范围映射到常春藤配置常春藤
With the following in ivy.xml
:
<dependency org="com.amazonaws" name="aws-java-sdk" rev="1.4.5">
<artifact name="aws-java-sdk" ext="jar"/>
</dependency>
It downloads aws-java-sdk-1.4.5.jar
and this is the AWS SDK, i.e. classes.
That's fine but I'd also like to get the Javadoc and sources.
Following advice from Ivy: Fetching Javadocs and Sources I put the following in ivy.xml
<configurations>
<conf name="default" />
<conf name="compile" visibility="public"/>
<conf name="sources" visibility="public"/>
<conf name="javadoc" visibility="public"/>
</configurations>
<dependency org="com.amazonaws" name="aws-java-sdk"
rev="1.4.5" transitive="true"
conf="javadoc->javadoc;sources->sources;compile->default"/>
It downloads aws-java-sdk-1.4.5.jar
only and it is the Javadoc (no class or source files).
Update: Snippets from files that might be useful
build.xml
<project name="aws-project" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="build" depends="clean,configure-ivy-settings,artifactory-retrieve">
ivy-config.xml
<project name="artifactory-bootstrap" xmlns:ac="http://ant-contrib.sourceforge.net" xmlns:ivy="antlib:org.apache.ivy.ant" default="configure-ivy-settings">
<target name="configure-ivy-settings" unless="skip.artifact.retrieve">
<echoproperties prefix="ivy" />
<!-- Change this to point to the branch in artifactory -->
<property name="artifactory.branch" value="20.0" />
<!-- Change this to the SRCROOT of your build -->
<property name="build.srcroot" value="${bootstrap.basedir}" />
<!-- Configure IVY Settings -->
<ivy:settings url="https://artifactory.mycompany.com/artifactory/simple/bootstrap/${artifactory.branch}/ivysetting-artifactory.xml" id="artifactory.ivy.settings" host="artifactory.mycompany.com" realm="Artifactory Realm" username="${artifactory.user}" passwd="${artifactory.password}" />
</target>
<target name="artifactory-retrieve" unless="skip.artifact.retrieve">
<property name="download.dir" value="${bootstrap.basedir}/extlib" />
<delete dir="${download.dir}" />
<mkdir dir="${download.dir}" />
<ivy:resolve settingsRef="artifactory.ivy.settings" file="${ivy.file}" />
<ivy:cachefileset settingsRef="artifactory.ivy.settings" setid="latest.downloads" />
<echo message="Artifacts are available at : ${download.dir}" />
<copy flatten="true" todir="${download.dir}">
<fileset refid="latest.downloads" />
</copy>
<fileset id="ivy.fileset" dir="${download.dir}">
<include name="*.jar" />
</fileset>
<property name="ivy.downloads.fileset" refid="ivy.fileset" />
<!-- Construct classpath to downloads //-->
<path id="ivy.classpath">
<fileset dir="${download.dir}">
<include name="*.jar" />
</fileset>
</path>
<property name="ivy.downloads.classpath" refid="ivy.classpath" />
<echo message="ivy.downloads.classpath=${ivy.downloads.classpath}"/>
<echo message="Artifacts are available at : ${download.dir}" />
<echo message="They can be referenced using fileset refid ivy.downloads.fileset or ivy.downloads.classpath" />
</target>
解决方案
Example
├── build
│ └── lib
│ ├── compile
│ │ ├── aws-java-sdk-1.4.5.jar
│ │ ├── commons-codec-1.3.jar
│ │ ├── commons-logging-1.1.1.jar
│ │ ├── httpclient-4.1.jar
│ │ ├── httpcore-4.1.jar
│ │ ├── jackson-core-asl-1.8.9.jar
│ │ └── jackson-mapper-asl-1.8.9.jar
│ ├── javadoc
│ │ └── aws-java-sdk-1.4.5-javadoc.jar
│ └── sources
│ └── aws-java-sdk-1.4.5-sources.jar
├── build.xml
└── ivy.xml
build.xml
<project name="demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="build" description="Compile code">
<ivy:retrieve pattern="build/lib/[conf]/[artifact]-[revision](-[classifier]).[ext]"/>
</target>
<target name="clean" description="Additionally purge ivy cache">
<delete dir="build"/>
<ivy:cleancache/>
</target>
</project>
Note:
- Ivy retrieve task uses a special pattern that puts files into different directories based on configuration.
- The classifier attribute is optional therefore enclosed within brackets.
ivy.xml
<ivy-module version="2.0">
<info organisation="com.myspotontheweb" module="demo"/>
<configurations>
<conf name="compile" description="Required to compile application"/>
<conf name="sources" description="Source code"/>
<conf name="javadoc" description="Javadocs"/>
</configurations>
<dependencies>
<dependency org="com.amazonaws" name="aws-java-sdk" rev="1.4.5" conf="compile->default;sources;javadoc"/>
</dependencies>
</ivy-module>
Note:
- The configuration mapping is comprised of 3 parts: "compile->default", "sources", "javadoc".
Update - Second example
Alternative directory layout this time:
├── build
│ ├── doc
│ │ └── aws-java-sdk-1.4.5-javadoc.jar
│ ├── lib
│ │ ├── aws-java-sdk-1.4.5.jar
│ │ ├── commons-codec-1.3.jar
│ │ ├── commons-logging-1.1.1.jar
│ │ ├── httpclient-4.1.jar
│ │ ├── httpcore-4.1.jar
│ │ ├── jackson-core-asl-1.8.9.jar
│ │ └── jackson-mapper-asl-1.8.9.jar
│ └── src
│ └── aws-java-sdk-1.4.5-sources.jar
├── build.xml
└── ivy.xml
build.xml
<project name="demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="build" description="Compile code">
<ivy:retrieve pattern="build/lib/[artifact]-[revision].[ext]" conf="compile"/>
<ivy:retrieve pattern="build/src/[artifact]-[revision](-[classifier]).[ext]" conf="sources"/>
<ivy:retrieve pattern="build/doc/[artifact]-[revision](-[classifier]).[ext]" conf="javadoc"/>
</target>
<target name="clean" description="Additionally purge ivy cache">
<delete dir="build"/>
<ivy:cleancache/>
</target>
</project>
Notes:
- Observe how each retrieve task is customized to place files in a particular directory. The configuration is used to determine the files used. Configurations are a grouping mechanism.
- Review again the "configuration mapping" on the dependency in the ivy file. This is the magic that determines how ivy classifies the downloaded files.
- For more details on configuration mappings, see: How are maven scopes mapped to ivy configurations by ivy
这篇关于获得一个罐子连同其来源和javadoc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文