ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Greenwood-Geer <t.greenwoodg...@gmail.com>
Subject Re: Managing an ivy repository and resolving dependencies
Date Fri, 17 Apr 2009 19:39:01 GMT
Tetyana and Antoine, thank you for your responses.

I'd like to refine my questions to a specific problem: I'm attempting to 
build a repo for a default Grails application. Grails auto-generates the 
app/ivy.xml and the app/ivysettings.xml, which resolve dependencies just 
fine, and the apps compile and run via ant&ivy with no problem.

My approach to building a local repo initially involved taking the 
app/ivy.xml, and migrating the app/ivy.xml:<dependencies...> to my 
repository/build.xml:<ivy:install...> tasks. However, I have found that 
this naive migration resulted in a number of unresolved dependencies, 
and that if I replaced the resolvers in app/ivysettings.xml (which 
resolve to ibiblio, etc.) with resolvers to my local filesystem, then 
ivy would download a significantly smaller subset of the dependencies 
needed by the grails app. Subsequently, the grails app would fail to 
compile or run.

So, my second approach has been to try to generate the local repo 
directly from the app/build.xml, using the original unmodified 
app/ivy.xml and app/ivysettings.xml. With this approach, ivy downloads 
the dependency artifacts to a staging area. Exciting stuff. However, I'm 
a bit stuck w/ respect to publishing. I'll include my targets below, but 
to wrap up, when I publish, only the top level object, my grails app, 
gets published. My goal is to publish not just the top level project (in 
fact, I don't really need this top level), but what I need to publish 
are all the dependencies of this project.

Looking at the docs 
(http://ant.apache.org/ivy/history/2.1.0-rc1/use/publish.html), I don't 
see anything re: publishing the dependencies of a module. What are my 
options here? Do I need to write some code to walk the directory where 
I'm staging all my dependencies, and publish each one in turn? Or is 
there a cleaner approach?

Here are my some of my artifacts:

#===============================================
#app/ivy.xml // grails generated
#===============================================
<ivy-module version="2.0">
     <info organisation="org.foo" module="asmc"/>
     <configurations 
defaultconfmapping="build->default;compile->compile(*),master(*);test,runtime->runtime(*),master(*)">
         <conf name="build"/>
         <conf name="compile"/>
         <conf name="test" extends="compile"/>
         <conf name="runtime" extends="compile"/>
     </configurations>
     <dependencies>
         <dependency org="org.grails" name="grails-bootstrap" 
rev="1.1-RC2" conf="build"/>
         <dependency org="org.grails" name="grails-scripts" 
rev="1.1-RC2" conf="build"/>
         <dependency org="org.grails" name="grails-gorm" rev="1.1-RC2" 
conf="compile"/>
         <dependency org="org.grails" name="grails-web" rev="1.1-RC2" 
conf="compile"/>
         <dependency org="org.grails" name="grails-test" rev="1.1-RC2" 
conf="test"/>
         <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.5.5" 
conf="runtime"/>
         <dependency org="opensymphony" name="oscache" rev="2.4" 
conf="runtime">
             <exclude org="javax.jms" module="jms" name="*" type="*" 
ext="*" conf="" matcher="exact"/>
             <exclude org="commons-logging" module="commons-logging" 
name="*" type="*" ext="*" conf="" matcher="exact"/>
             <exclude org="javax.servlet" module="servlet-api" name="*" 
type="*" ext="*" conf="" matcher="exact"/>
         </dependency>
         <dependency org="hsqldb" name="hsqldb" rev="1.8.0.5" 
conf="runtime"/>
         <dependency org="mysql" name="mysql-connector-java" rev="5.1.6" 
conf="runtime"/>
         <!--
         <dependency org="mysql" name="mysql-connector-java" rev="5.1.6" 
conf="runtime"/>
         <dependency org="postgresql" name="postgresql" 
rev="8.3-603.jdbc3" conf="runtime"/>
         -->
     </dependencies>
</ivy-module>

#===============================================
#app/build.xml // my custom tasks for dependency publishing
#===============================================

     <!-- =================================
           target: resolve and publish dependencies to staging repository
          ================================= -->
     <target name="-resolve-deps-to-staging" description="--> Resolve 
application dependencies to staging repository" depends="init-ivy">
         <ivy:retrieve
 
pattern="${foo.repo.staging.dir}/foo/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"
 
ivypattern="${foo.repo.staging.dir}/foo/[organisation]/[module]/ivys/ivy-[revision].xml"
         />
     </target>

     <!-- =================================
           target: publish dependencies from staging repository to repo
          ================================= -->
     <target name="publish" description="--> Publish application 
dependencies from staging to repository" depends="-resolve-deps-to-staging">
         <ivy:publish resolver="foo-repo" pubrevision="1.0">
             <artifacts 
pattern="${foo.repo.staging.dir}/foo/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
             <artifacts 
pattern="${foo.repo.staging.dir}/foo/[organisation]/[module]/ivys/ivy-[revision].xml"/>
         </ivy:publish>
     </target>

#===============================================
#repo/staging // subset of what gets downloaded
#===============================================
toddg@LAPTOP:~/src/Main/FOO/etc/project/main/foo-ivy-repo/staging/foo$ 
find xpp3/
xpp3/
xpp3/xpp3_min
xpp3/xpp3_min/ivys
xpp3/xpp3_min/ivys/ivy-1.1.3.4.O.xml
xpp3/xpp3_min/jars
xpp3/xpp3_min/jars/xpp3_min-1.1.3.4.O.jar

#===============================================
#repo/staging // subset of what gets downloaded
#===============================================
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="1.0" xmlns:m="http://ant.apache.org/ivy/maven">
	<info organisation="xpp3"
		module="xpp3_min"
		revision="1.1.3.4.O"
		status="release"
		publication="20060218133216"
	>
		<description 
homepage="http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1/">
		MXP1 is a stable XmlPull parsing engine that is based on ideas from 
XPP and in particular XPP2 but completely revised and rewritten to take 
the best advantage of latest JIT JVMs such as Hotspot in JDK 1.4+.
		</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="xpp3_min" type="jar" ext="jar" conf="master"/>
	</publications>
</ivy-module>

Again, thank you for your time.
-Todd

Mime
View raw message