migration from private cvs repository

git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@483981 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2005-06-16 11:18:39 +00:00
commit f2b71e8c0b
285 changed files with 20411 additions and 0 deletions

15
.classpath Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.0.0/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
<classpathentry sourcepath="/ANT_HOME/src/main" kind="var" path="ANT_HOME/lib/ant.jar"/>
<classpathentry kind="var" path="ANT_HOME/lib/ant-launcher.jar"/>
<classpathentry kind="var" path="ANT_HOME/lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="lib/commons-cli-1.0.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-2.0.2.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-1.0.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ivy</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

170
CHANGES.txt Normal file
View File

@ -0,0 +1,170 @@
version 1.1 - 2005-06-13
===============================
- remote configuration (if available) of ivyrep and ibiblio patterns and roots
- new detailed messages when ivy fails to reach an url (thanks to Nicolas)
- new artifactproperty task, which enables to set a property for each dependency artifacts
resolved by ivy
- new defaultconf attribute in ivy file dependencies, to change the default conf to use in the file
when no conf is specified for a dependency
- add the ability to change the xsl file and report name pattern used by report task
- http listing now compatible with tomcat listing (tested with 5.0.28)
- pub revision in deliver task now defaults to timestamp if not provided by any other way
- debug messages improvements, with configuration dump among others
- new var task, enables to set ivy variables from ant
- now defaults for ivyrep and ibiblio resolver are configurable by variables
- refactoring: introduce the notion of BasicResolver, Repository, Resource, RepositoryResolver,
making much easier the task of writing basic resolvers
- added checkmodified attribute on all basic resolvers, which defaults to ${ivy.resolver.default.check.modified}
This makes ivy check last modified date of ivy files to see it its cache is up to date
- artifacts download are now first made to a temp file, which is renamed
only at the end of the download. This prevent interrupted downloads to be
considered as finished
- FIX: handle proxy configuration with http-client (thanks to Nicolas)
- FIX: remove dependency on ant outside of ant integration classes
- FIX: resolve problem when conflicts on latest revisions
- FIX: allow use of any kind of URL in IvyRepResolver (both ivyroot and artroot) and IBibiblioResolver
- FIX: chain resolver can now be used for artifacts part of dual resolver
- FIX: now detects and warn about circular dependencies
- FIX: cachepath task now takes pathid as parameter instead of id, to prevent
special handling from ant
- FIX: ivy.xsd: set artifact minOccurs to 0 in publications
Thanks to John Shields from Robert Half International, Inc.:
- FIX: no more infinite loop when a conflict occurs between a latest subversion and a fully resolved revision
- FIX: BasicURLHandler now closes its connections
- FIX: ApacheURLLister now works with capital letter in revisions and truncated names
- now use of ivy variables is allowed in ivy files
- added a null check in pattern helper substitute
version 1.0 - 2005-04-26
===============================
1.0-rc3 has been promoted to 1.0 on 2005-04-26
Known bugs and limitations:
- cyclic dependencies result in StackOverflowError
- infinite loop in rare cases when a conflict occur between a latest subversion and a fully resolved revision
- url connections not closed properly when not using commons-httpclient
- latest does not work with http urls in some cases, when the name of the link is truncated in the web page
version 1.0-rc3 - 2005-04-21
===============================
- IMPROVE: added debug messages on variables setting
- FIX: ivyconf now able to load a properties file given as url
- FIX: deliver pub date now actually defaults to 'now'
- FIX: all tasks attributes now substitute ivy variables
version 1.0-rc2 - 2005-04-18
===============================
- IMPROVE: improved messages: more debug, more verbose, and more details on failures
- FIX: bug with '\' in path patterns
- FIX: bug with relative paths patterns
- FIX: configure task tries ivy.conf.file as relative to base dir and to current dir
- FIX: file system resolver publishes ivy files with ivy pattern
- FIX: 0 content length considered as non existing (behaviour of jre 5.0 on linux)
=> empty ressources are now considered as non existing
version 1.0-rc1 - 2005-04-12
===============================
- add report task, which enables to generates reports of dependencies, including a graph
ready to be layed out by yEd
- add exclude feature in dependency
- include exclude feature now handles regexps
- new latest strategy: latest revision now uses a "php version_compare" like algorithm, whereas
lexicographic comparison is now available in latest lexicographic
- enhance xml resolve report details
- FIX: better separation between root configurations
- FIX: XmlModuleDescriptorUpdater now preserves xml header
- FIX: modules number in report (displayed at the end of resolve)
version 0.9 - 2005-04-06
===========================
- clearly differenciate pattern tokens from variables, by using brackets as delimiter in pattern tokens
=> WARNING: this introduce changes in all patterns syntax, and thus does not provide compatibility
with previous versions
- ChainResolver are now able to publish (delegating the call to the first resolver in the chain)
- DualResolver sub resolvers are now registered in Ivy
- more precise message on eviction
- add validate attribute on most resolvers
- ivy files validation handling review
- use ivy variables in ant tasks to get default values for attributes
- documentation update for configuring ivy
- FIX: dependencies order not taken into account during resolve
- FIX: evicting modules also evict confs
- FIX: NPE during resolve when a dependency ivy file has no publication date
- FIX: check nullity of artifact download reports
version 0.8 - 2005-03-30
===========================
- added validate attribute on resolve, retrieve and publish, which allows to disable ivy file validation
against ivy.xsd (useful to parse future compatible ivy files)
- ant properties are now available in ivyconf file
- unified default properties in ivyconf, with better independance from url or file
- added ext on artifacts: this enable to distinguish artifact extension from artifact
type, util in cases where it differs (example: 'src' type with 'zip' extension, 'ivy' type with 'xml' extension, ...)
- added publish artifacts feature, which enable to publish declared artifacts of a module to a repository
described by a dependency resolver. It currently works only with filesystem resolver.
- url resolver now handles latest with file urls and http ones (tested only with apache server)
- added latest strategy concept: the way to determine which artifact is the latest
is now configurable on resolvers handling latest.
- added parameter on chain resolver to say if it should return first found or
try to find the latest among all if asked
- a module can now publish no artifact, useful for virtual modules consisting only
of integration of other modules
- added conflict management at resolve time: during resolve, modules in conflict can be evicted
and thus not downloaded
- added ivyrep resolver, using ivyrep to find ivy files, and ibiblio for artifacts
- use ivyrep instead of ibiblio as default resolver
- added more info in ivy files (description, homepage, ivy authors, license, public repository, ...)
- now cache layout is configurable, using cacheIvyPattern and cacheArtifactPattern
attributes on conf element in ivyconf.xml
- changed default cache layout: artifacts are separated by type
- added cachepath task, which enables to build an ant path of artifacts in cache required for a conf
version 0.7 - 2005-03-11
===========================
- added latest sub revision feature: you can now select the latest sub revision of a module
using a +. For instance, "1.0+" selects the latest revision starting with 1.0. (thanks to jonas for the idea)
- haltonfailure now defaults to true (as suggested by Jeroen)
- shorter info lines to better view important info (as suggested by Jeroen)
- retrieve now checks if files are up to date before copying them from cache. This feature
can be disabled using the checkUpToDate attribute in ivy configuration file.
- do not download dependencies when not necessary during publication (as suggested by Daniele)
- bug fix: better handling of publish without recursive delivery
version 0.6.1 - 2005-02-11
=============================
- bug fix: conf extends problem with publications
- bug fix: typedef badly handled in ivyconf.xml
- bug fix: default properties loading in ivy configure loaded using task classloader
version 0.6 - 2005-02-03
===========================
+ functional
- added haltonfailure attribute on resolve and retrieve task, so that build can be halt when
resolve or retrieve fails
- added dependency artifacts filtering feature, enabling to work better with ibiblio
- ibiblio resolver can now be configured to use any maven like repository, with root and pattern attributes
- added download progression info on resolve
- default cache is now in user home (.ivy-cache in user home), so that cache is shared
by default for all projects of the same user
- added public access to method getDependencies(...) in Ivy, which resolve dependencies without
downloading artifacts
- added DualResolver, which allows to have ivy files in one place and artifacts in another one
+ non functional
- added some unit tests
- deep review of ivy file reference documentation
+ bugs and refactoring
- bug fix: SimpleURLResolver not handling the case when there is no ivy file
- refactoring: URLResolver renamed to AbstractURLResolver
- refactoring: SimpleURLResolver renamed to URLResolver
version 0.5.1 - 2005-01-16
=============================
- Bug Fix: NPE in publish task when no delivery.list.file is provided
- documentation update
version 0.5 - 2005-01-12
===========================
initial public version

26
LICENSE.txt Normal file
View File

@ -0,0 +1,26 @@
BSD License for Ivy
Copyright (c) 2005, JAYASOFT
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of JAYASOFT nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

9
build.properties Normal file
View File

@ -0,0 +1,9 @@
lib.dir=lib
src.dir=src/java
test.dir=test/java
build.dir=build
classes.build.dir=build/classes
test.build.dir=build/test
artifacts.build.dir=build/artifact
test.report.dir=build/report

87
build.xml Normal file
View File

@ -0,0 +1,87 @@
<project name="ivy" default="test" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<property file="build.properties"/>
<target name="prepare">
<mkdir dir="${classes.build.dir}"/>
<mkdir dir="${test.build.dir}"/>
<mkdir dir="${artifacts.build.dir}"/>
<mkdir dir="${test.report.dir}"/>
</target>
<target name="clean">
<delete dir="${classes.build.dir}"/>
<delete dir="${test.build.dir}"/>
<delete dir="${artifacts.build.dir}"/>
<delete dir="${test.report.dir}"/>
<delete dir="${build.dir}"/>
</target>
<target name="clean-lib">
<delete dir="${lib.dir}"/>
</target>
<target name="clean-examples" description="clean all examples">
<subant target="clean" failonerror="false">
<fileset dir="src/example" includes="**/build.xml"/>
</subant>
</target>
<target name="clean-all" depends="clean, clean-lib, clean-examples"/>
<target name="resolve" depends="prepare">
<ivy:retrieve/>
</target>
<target name="build" depends="resolve">
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<javac srcdir="${src.dir}"
destdir="${classes.build.dir}"
classpathref="build.classpath"
debug="on"/>
</target>
<target name="jar" depends="build">
<copy todir="${classes.build.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
<jar destfile="${artifacts.build.dir}/ivy.jar"
basedir="${classes.build.dir}"/>
</target>
<target name="test" depends="jar">
<path id="run.classpath">
<path refid="build.classpath"/>
<pathelement location="${artifacts.build.dir}/ivy.jar"/>
</path>
<javac srcdir="${test.dir}"
destdir="${test.build.dir}"
classpathref="run.classpath"
debug="on"/>
<copy todir="${test.build.dir}">
<fileset dir="${test.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
<junit haltonfailure="on"
showoutput="no"
printsummary="yes">
<classpath>
<path refid="run.classpath"/>
<pathelement path="${test.build.dir}"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${test.report.dir}">
<fileset dir="${test.dir}">
<include name="**/*Test.java"/>
<contains text="junit"/>
</fileset>
</batchtest>
</junit>
</target>
</project>

View File

@ -0,0 +1,35 @@
################################ French ########################################
La société Jayasoft (http://www.jayasoft.org) a le plaisir d'annoncer la version 0.5, première version publique, de son outil de résolution de dépendances nommé Ivy.
Ivy est un outil, écrit en Java, qui peut etre utilisé avec ant ou bien seul.
Les principaux atouts d'Ivy sont :
- la simplicité,
- la flexibilité,
- l'extensibilité,
- l'intégration avec ant,
- le support de dépendance de dépendance,
- la comptatibilité avec le repository maven sur ibiblio,
- facilite l'intégration continue,
- la gratuité, en licence BSD.
Plus d'informations et téléchargement sur le site : http://ivy.jayasoft.org
################################ English ########################################
Jayasoft (http://www.jayasoft.org) is pleased to announce the availabilty of the first public beta of Ivy, version 0.5.
Ivy is a java based simple but powerful dependency manager.
Key features are :
* simple to use
* extremely flexible
* easily extensible
* xml based
* integrated with ant
* ready to use with maven ibiblio repository
* dependencies of dependencies
* eases continuous integration
* make your software component a lot simpler to use
* free (BSD license) !
Download and information on : http://ivy.jayasoft.org

View File

@ -0,0 +1,16 @@
Jayasoft (http://www.jayasoft.org) is pleased
to announce the availability of Ivy version 0.6, a free java based simple but powerful
dependency manager, featuring transitive dependencies, ant integration,
maven repository compatibility and many more.
Main changes in this version are :
- dependency artifacts filtering feature, enabling to work better with ibiblio
- ibiblio resolver can now be configured to use any maven like repository
- a new dependency resolver which allows to have ivy files in one place
and artifacts in another one (named dual resolver)
- a new logo, many thanks to ultroniks (at) hotmail.com
And more...
Download and information on : http://ivy.jayasoft.org

View File

@ -0,0 +1,16 @@
Jayasoft (http://www.jayasoft.org) is pleased
to announce the availability of Ivy version 0.7, a free java based simple but powerful
dependency manager, featuring transitive dependencies, ant integration,
maven repository compatibility, continuous integration features and many more.
Main changes in this version are :
- added latest sub revision feature: you can now select the latest sub revision of a module
using a +. For instance, "1.0+" selects the latest revision starting with 1.0.
- retrieve now checks if files are up to date before copying them from cache. This feature
can be disabled using the checkUpToDate attribute in ivy configuration file.
- do not download dependencies when not necessary during publication
And more...
Download and information on : http://ivy.jayasoft.org

View File

@ -0,0 +1,12 @@
Jayasoft (http://www.jayasoft.org) is pleased to announce the availability of Ivy version 0.8, a free java based simple but powerful dependency manager, featuring transitive dependencies, ant integration, maven repository compatibility, continuous integration features and many more.
Main changes in this version are :
- a brand new public repository of ivy files, <a href="http://www.jayasoft.fr/org/ivyrep/">ivyrep</a>, which helps leverage the transitive dependencies feature
- url resolver now handles latest with file urls and http ones: you can now use continuous integration feature with ibiblio !
- publish artifacts feature, which enable to easily publish declared artifacts of a module to a repository
- conflict management at resolve time, which gives great control over conflicts management and evict modules before downloading them
And many more...
Download and information on : http://ivy.jayasoft.org

View File

@ -0,0 +1,13 @@
After several months of development and testing, <a href="http://www.jayasoft.org">Jayasoft</a> is pleased to announce the availability of Ivy version 1.0-rc1.
Ivy is a free java based dependency manager, with powerful features such as transitive dependencies, ant integration, maven repository compatibility, continuous integration and many more.
Main changes in this version are :
- new report, which indicates all the dependencies resolved, direct and transitives, with the status and place in the dependency graph for each
- new graph report, showing all dependencies as a graph
- better include/exclude feature, helping to get only what you need from a dependency you do not control
And many more...
Download and information on : http://ivy.jayasoft.org

View File

@ -0,0 +1,40 @@
English:
--------
After several months of development and testing, <a href="http://www.jayasoft.org">Jayasoft</a> is pleased to announce the availability of Ivy version 1.0.
<a href="http://ivy.jayasoft.org">Ivy</a> is a free java based dependency manager, with powerful features such as transitive dependencies, ant integration, maven repository compatibility, continuous integration, html reports and many more.
Apart its strong dependency management engine, Ivy also benefits from a growing user community, a <a href="http://www.jayasoft.fr/org/ivyrep/">public repository</a> of common ivy files, and <a href="http://www.jayasoft.fr/org/modules/ivy/services.php">professional quality services</a> from the source.
And leverage the power of Ivy with an evolving set of tools and plugins:
<a href="http://www.jayasoft.org/modules/ivycruise/">Ivy CruiseControl Plugin</a> lets you integrate ivy in the famous continuous integration tool from thoughtworks: cruisecontrol.
<a href="http://www.jayasoft.org/modules/ivyeclipseui/">Ivy Eclipse UI</a> strongly helps eclipse users to write their ivy files, with structural and data completion.
Coming soon:
Subversion Dependency Resolver, lets you use subversion to store your libraries
Ivy Eclipse Classpath, lets you use ivy files as a library container
Finally, many thanks to the users feedbacks and contributions who made this possible.
Download and information on : <a href="http://ivy.jayasoft.org">http://ivy.jayasoft.org</a>
French :
--------
Après plusieurs mois de développement et de tests, <a href="http://www.jayasoft.org">Jayasoft</a> a le plaisir d'annoncer la version 1.0 de Ivy.
<a href="http://ivy.jayasoft.org">Ivy</a> est un outil de gestion de dépendances écrit en java, doté de fonctionalités avancées telles que la gestion de dépendances transitives, l'intégration dans ant, la compatibilité avec les repository maven, l'intégration continue, des fonctions de rapport avancées et bien d'autres encore.
En plus de son puissant moteur de gestion de dépendances, Ivy bénéficie également d'une communauté utilisateurs grandissante, d'un repository public de fichiers ivy communs et de services professionnels directement par ses auteurs.
Et profitez de toute la puissance d'une ensemble d'outils en pleine évolution :
<a href="http://www.jayasoft.org/modules/ivycruise/">Ivy CruiseControl Plugin</a> vous permet d'intégrer ivy dans l'outil d'intégration continue de thoughtworks: cruisecontrol.
<a href="http://www.jayasoft.org/modules/ivyeclipseui/">Ivy Eclipse UI</a> permet aux utilisateurs d'eclipse d'écrire leurs fichiers de dépendances encore plus rapidement, grâce à de la completion de structure et de données !
Et bientôt :
<b>Subversion Dependency Resolver</b> vous permettra d'utiliser subversion comme repository
<b>Ivy Eclipse Classpath</b> vous permettra d'utiliser les dépendances Ivy directement comme library container eclipse
Finalement, un grand merci aux utilisateurs, dont les retours et les contributions ont permis de faire de Ivy ce qu'il est aujourd'hui.
Plus d'informations et téléchargement sur le site : http://ivy.jayasoft.org

View File

@ -0,0 +1,14 @@
English:
--------
<a href="http://www.jayasoft.org">Jayasoft</a> is pleased to announce the availability of Ivy version 1.1.
<a href="http://ivy.jayasoft.org">Ivy</a> is a free java based dependency manager, with powerful features such as transitive dependencies, ant integration, maven repository compatibility, continuous integration, html reports and many more.
Apart its strong dependency management engine, Ivy also benefits from a growing user community, a <a href="http://ivyrep.jayasoft.org/">public repository</a> of common ivy files, and <a href="http://www.jayasoft.org/services">professional quality services</a> from the source.
This release includes many bug fixes, better download management, better information and debug messages, improved documentation and a brand new web site !
Finally, many thanks to the users feedbacks and contributions who made this possible.
Download and information at : <a href="http://ivy.jayasoft.org">http://ivy.jayasoft.org</a>

View File

@ -0,0 +1,97 @@
<html>
Here are some explanations about the conflict management algorithm in Ivy.<br/><br/>
First, one should have a good understanding on how Ivy resolves dependencies, and especially
transitive dependencies.<br/><br/>
During the resolve process, ivy visits each module of the dependency graph. <br/>
Let's call each module a <b>node</b>, including the module we are trying to resolve dependencies for.<br/><br/>
Each node should be able to give a conflict manager for a particular ModuleId.<br/>
Let's name it <b>node.cm(mid)</b>.<br/><br/>
Each node should be able to matain a map from ModuleId to a resolved Collection of nodes.<br/>
This resolved collection will never contain any evicted node FOR the concerned node as far
as ivy knows, dependening on where it is in graph visit.<br/>
Let's call this map resolved, and the corresponding resolved collection <b>node.resolved(mid)</b>.<br/><br/>
During the visit, ivy should always know from which node it came to visit another node. Let's call
the first node from which ivy came <b>node.parent</b>. Note that this concept is slightly different from
node parent, since a node can have several parents in the graph, but there is also one <b>node.parent</b>
during the visit.<br/><br/>
Let's say that a conflict manager is able to filter a collection of nodes to return only those
that are not evicted. Let's call that <b>cm.resolveConflicts(collection)</b>.<br/><br/>
Let's call <b>node.dependencies</b> the collection of direct dependencies of a node.<br/><br/>
Let's call <b>node.revision</b> the module revision id of a node.<br/><br/>
And now for the algo. This algo attempts to evict nodes on the fly, i.e. during the ivy visit,
to minimize the number of resolved modules, and thus the number of ivy files to download.<br/><br/>
It is presented in a very simplified description language, far away from the whole real complexity,
but giving a good understanding of how it works. In particular, it completely hides some complexity due
to configurations management.<br/><br/>
<pre>
resolve(node) {
node.resolved(node.mid) = <i>collection</i>(node);
resolveConflict(node, node.parent, empty);
if (!node.evicted && !node.alreadyResolved) {
node.loadData();
resolveConflict(node, node.parent, empty);
if (!node.evicted) {
// actually do resolve
foreach (dep in node.dependencies) {
resolve(dep);
}
}
}
}
resolveConflict(node, parent, toevict) {
if (node.revision.exact && parent.resolved(node.mid).revision.contains(node.revision)) {
// exact revision already in resolved
// => job already done
return;
}
if (parent.resolved(node.mid).containsAny(toevict)) {
// parent.resolved(node.mid) is not up to date:
// recompute resolved from all sub nodes
resolved = parent.cm(node.mid).resolveConflicts(
parent.dependencies.resolved(node.mid));
} else {
resolved = parent.cm(node.mid).resolveConflicts(<i>collection</i>(node, parent.resolved(node.mid)));
}
if (resolved.contains(node)) {
// node has been selected for the current parent
// we update its eviction... but it can still be evicted by parent !
node.evicted = false;
// handle previously selected nodes that are now evicted by this new node
toevict = parent.resolved(node.mid) - resolved;
foreach (te in toevict) {
te.evicted = true;
}
// it's very important to update resolved BEFORE recompute parent call
// to allow it to recompute its resolved collection with correct data
// if necessary
parent.resolved(node.mid) = resolved;
if (parent.parent != null) {
resolveConflict(node, parent.parent, toevict);
}
} else {
// node has been evicted for the current parent
// it's time to update parent resolved with found resolved...
// if they have not been recomputed, it does not change anything
parent.resolved(node.mid) = resolved;
node.evicted = true;
}
}
</pre>
</html>

13
doc/index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Ivy Documentation Index</title>
</head>
<body>
<h1>Welcome to Ivy documentation index !</h1>
Here is what you can find in this documentation:<br/>
- <a href="build/main/index.html">Main documentation</a><br/>
- <a href="build/api/index.html">Javadoc</a><br/>
- <a href="build/report/junit/junit-noframes.html">JUnit tests report</a><br/>
</body>

10
ivy.xml Normal file
View File

@ -0,0 +1,10 @@
<ivy-module version="1.0">
<info organisation="jayasoft"
module="ivy"
status="integration"
/>
<dependencies>
<dependency org="apache" name="commons-httpclient" rev="2.0.2" conf="default"/>
<dependency org="apache" name="commons-cli" rev="1.0" conf="default"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,18 @@
<project default="clean-all">
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean directories">
<ant dir="chainedresolvers-project" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<delete dir="${user.home}/.ivy-cache"/>
</target>
<target name="clean-all" depends="clean, clean-cache" description="--> clean directories and ivy cache"/>
</project>

View File

@ -0,0 +1,68 @@
<project name="chainedresolvers-project" default="run" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<!-- some variables used -->
<property name="lib.dir" value="${basedir}/lib" />
<property name="build.dir" value="${basedir}/build" />
<property name="src.dir" value="${basedir}/src" />
<!-- ivy properties used -->
<property name="ivy.conf.dir" value="../config" />
<!-- paths used for compilation and run -->
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${build.dir}" />
</path>
<!-- - - - - - - - - - - - - - - - - -
target: configure
- - - - - - - - - - - - - - - - - -->
<target name="configure">
<ivy:configure file="${ivy.conf.dir}/ivyconf.xml" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="configure" description="--> retreive dependencies with ivy">
<ivy:retrieve />
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: run
================================= -->
<target name="run" depends="resolve" description="--> compile and run the project">
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id" />
<java classpathref="run.path.id" classname="example.Hello"/>
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean the project">
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<exclude name="src/**" />
<exclude name="build.xml" />
<exclude name="ivy.xml" />
</fileset>
</delete>
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<delete dir="${user.home}/.ivy-cache"/>
</target>
</project>

View File

@ -0,0 +1,7 @@
<ivy-module version="1.0">
<info organisation="jayasoft" module="chained-resolvers"/>
<dependencies>
<dependency org="apache" name="commons-lang" rev="2.0"/>
<dependency name="test" rev="1.0"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,20 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package example;
import org.apache.commons.lang.WordUtils;
/**
* Simple example world to show how easy it is to retreive libs with ivy !!!
*/
public class Hello {
public static void main(String[] args) {
String message = "example world !";
System.out.println("standard message :" + message);
System.out.println("capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message));
System.out.println("upperCased by " + test.StringUtils.class.getName() + " : " + test.StringUtils.upperCase(message));
}
}

View File

@ -0,0 +1,11 @@
<ivyconf>
<conf defaultResolver="chain-example"/>
<resolvers>
<chain name="chain-example">
<filesystem name="libraries">
<artifact pattern="${ivy.conf.dir}/repository/[artifact]-[revision].[ext]" />
</filesystem>
<ibiblio name="ibiblio" />
</chain>
</resolvers>
</ivyconf>

View File

@ -0,0 +1,24 @@
<project default="clean">
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean directories">
<delete includeemptydirs="true">
<fileset dir="config" excludes="ivyconf.*" />
</delete>
<ant dir="standalone" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
<ant dir="depending" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
</target>
<!-- =================================
target: all
================================= -->
<target name="all" depends="clean" description="--> make the whole example of dependency">
<ant dir="standalone" antfile="build.xml" target="publish" inheritall="false" inheritrefs="false" />
<ant dir="depending" antfile="build.xml" inheritall="false" inheritrefs="false" />
<ant dir="standalone" antfile="build.xml" target="publish" inheritall="false" inheritrefs="false" />
<ant dir="depending" antfile="build.xml" inheritall="false" inheritrefs="false" />
</target>
</project>

View File

@ -0,0 +1 @@
repository.dir=${ivy.conf.dir}/repository

View File

@ -0,0 +1,14 @@
<ivyconf>
<properties file="${ivy.conf.dir}/ivyconf.properties"/>
<conf defaultCache="${ivy.conf.dir}/ivy-cache" defaultResolver="libraries"/>
<resolvers>
<filesystem name="projects">
<artifact pattern="${repository.dir}/[artifact]-[revision].[ext]" />
<ivy pattern="${repository.dir}/[module]-[revision].xml" />
</filesystem>
<ivyrep name="libraries" />
</resolvers>
<modules>
<module organisation="jayasoft" name=".*" resolver="projects"/>
</modules>
</ivyconf>

View File

@ -0,0 +1,68 @@
<project name="depending" default="run" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<!-- some variables used -->
<property name="lib.dir" value="${basedir}/lib" />
<property name="build.dir" value="${basedir}/build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="src.dir" value="${basedir}/src" />
<!-- ivy properties used -->
<property name="ivy.conf.dir" value="../config" />
<property file="${ivy.conf.dir}/ivyconf.properties" />
<!-- paths used for compilation and run -->
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${classes.dir}" />
</path>
<!-- - - - - - - - - - - - - - - - - -
target: configure
- - - - - - - - - - - - - - - - - -->
<target name="configure">
<ivy:configure file="${ivy.conf.dir}/ivyconf.xml" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="configure" description="--> retreive dependencies with ivy">
<ivy:retrieve />
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" depends="resolve" description="--> description">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" />
</target>
<!-- =================================
target: run
================================= -->
<target name="run" depends="clean, compile" description="--> compile and run the project">
<java classpathref="run.path.id" classname="depending.Main"/>
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean the project">
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<exclude name="src/**" />
<exclude name="build.xml" />
<exclude name="ivy.xml" />
</fileset>
</delete>
</target>
</project>

View File

@ -0,0 +1,6 @@
<ivy-module version="1.0">
<info organisation="jayasoft" module="depending"/>
<dependencies>
<dependency name="standalone" rev="latest.integration" />
</dependencies>
</ivy-module>

View File

@ -0,0 +1,23 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package depending;
/**
* TODO write javadoc
*/
public class Main {
public static void main(String[] args) {
String standaloneVersion = standalone.Main.getVersion();
if (standaloneVersion!=null) {
System.out.println("you are using version " + standaloneVersion + " of class " + standalone.Main.class.getName());
} else {
System.err.println("failed to get version of " + standalone.Main.class.getName());
}
String message = "i am " + Main.class.getName() + " and " + standalone.Main.class.getName() + " will do the job for me";
System.out.println("standard message : " + message);
System.out.println("capitalized message : " + standalone.Main.capitalizeWords(message));
}
}

View File

@ -0,0 +1,97 @@
<project name="standalone" default="run" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<!-- some variables used -->
<property name="lib.dir" value="${basedir}/lib" />
<property name="build.dir" value="${basedir}/build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="src.dir" value="${basedir}/src" />
<!-- ivy properties used -->
<property name="ivy.conf.dir" value="../config" />
<property file="${ivy.conf.dir}/ivyconf.properties" />
<!-- paths used for compilation and run -->
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${classes.dir}" />
</path>
<!-- - - - - - - - - - - - - - - - - -
target: configure
- - - - - - - - - - - - - - - - - -->
<target name="configure">
<ivy:configure file="${ivy.conf.dir}/ivyconf.xml" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="configure" description="--> retreive dependencies with ivy">
<ivy:retrieve />
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" depends="resolve" description="--> description">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" />
</target>
<!-- =================================
target: run
================================= -->
<target name="run" depends="compile" description="--> compile and run the project">
<java classpathref="run.path.id" classname="standalone.Main"/>
</target>
<!-- =================================
target: jar
================================= -->
<target name="jar" depends="compile" description="--> make a jar file for this project">
<propertyfile file="${classes.dir}/version.properties">
<entry key="version" type="int" operation="+" default="0" />
</propertyfile>
<property file="${classes.dir}/version.properties" />
<jar destfile="${build.dir}/${ant.project.name}.jar">
<fileset dir="${classes.dir}" />
</jar>
</target>
<!-- =================================
target: publish
================================= -->
<target name="publish" depends="jar" description="--> publish this project in the ivy repository">
<property name="revision" value="${version}"/>
<delete file="${build.dir}/ivy.xml"/>
<ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
resolver="projects"
pubrevision="${revision}"
status="release"
/>
<echo message="project ${ant.project.name} released with version ${revision}" />
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean the project">
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<exclude name="src/**" />
<exclude name="build.xml" />
<exclude name="ivy.xml" />
</fileset>
</delete>
</target>
</project>

View File

@ -0,0 +1,6 @@
<ivy-module version="1.0">
<info organisation="jayasoft" module="standalone"/>
<dependencies>
<dependency org="apache" name="commons-lang" rev="2.0"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,48 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package standalone;
import java.util.Properties;
import org.apache.commons.lang.WordUtils;
/**
* TODO write javadoc
*/
public class Main {
/**
* Returns the version of the project
* @return a string representation of the version, null if the version could not be retreived
*/
public static String getVersion() {
Properties p = new Properties();
try {
p.load(Main.class.getResourceAsStream("/version.properties"));
String version = p.getProperty("version");
if (version != null) {
return String.valueOf(Integer.parseInt(version));
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* Return the same string with all words capitalized.
* @param str the string conatining the words to capitalize
* @return null if the string was null, the string with all words capitalized otherwise
*/
public static String capitalizeWords(String str) {
System.out.println(" [" + Main.class.getName() + "] capitalizing string \"" + str + "\" using " + WordUtils.class.getName());
return WordUtils.capitalizeFully(str);
}
public static void main(String[] args) {
String message="sentence to capitalize";
System.out.println("standard message : " + message);
System.out.println("capitalized message : " + capitalizeWords(message));
}
}

View File

@ -0,0 +1,18 @@
<project default="clean-all">
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean directories">
<ant dir="project" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<delete dir="${user.home}/.ivy-cache"/>
</target>
<target name="clean-all" depends="clean, clean-cache" description="--> clean directories and ivy cache"/>
</project>

View File

@ -0,0 +1,11 @@
<ivyconf>
<conf defaultResolver="dual-example"/>
<resolvers>
<dual name="dual-example">
<filesystem name="ivys">
<ivy pattern="${ivy.conf.dir}/../repository/[module]-ivy-[revision].xml" />
</filesystem>
<ibiblio name="ibiblio" />
</dual>
</resolvers>
</ivyconf>

View File

@ -0,0 +1,69 @@
<project name="dual-ivy" default="run" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<!-- some variables used -->
<property name="lib.dir" value="${basedir}/lib" />
<property name="build.dir" value="${basedir}/build" />
<property name="src.dir" value="${basedir}/src" />
<!-- ivy properties used -->
<property name="ivy.conf.dir" value="../config" />
<!-- paths used for compilation and run -->
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${build.dir}" />
</path>
<!-- - - - - - - - - - - - - - - - - -
target: configure
configures ivy with the appropriate ivyconf.xml file
- - - - - - - - - - - - - - - - - -->
<target name="configure">
<ivy:configure file="${ivy.conf.dir}/ivyconf.xml" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="configure" description="--> retrieve dependencies with ivy">
<ivy:retrieve />
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: run
================================= -->
<target name="run" depends="resolve" description="--> compile and run the project">
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id" />
<java classpathref="run.path.id" classname="example.Hello"/>
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean the project">
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<exclude name="src/**" />
<exclude name="build.xml" />
<exclude name="ivy.xml" />
</fileset>
</delete>
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<delete dir="${user.home}/.ivy-cache"/>
</target>
</project>

View File

@ -0,0 +1,7 @@
<ivy-module version="1.0">
<info organisation="jayasoft" module="hello-ivy"/>
<dependencies>
<dependency org="apache" name="commons-httpclient" rev="2.0.2"/>
<dependency org="apache" name="commons-lang" rev="2.0"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,37 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package example;
import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.lang.WordUtils;
/**
* Simple hello world example to show how easy it is to retrieve libs with ivy,
* including transitive dependencies
*/
public class Hello {
public static void main(String[] args) throws Exception {
String message = "hello ivy !";
System.out.println("standard message : " + message);
System.out.println("capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message));
HttpClient client = new HttpClient();
HeadMethod head = new HeadMethod("http://www.ibiblio.org/");
client.executeMethod(head);
int status = head.getStatusCode();
System.out.println("head status code with httpclient: "+status);
head.releaseConnection();
System.out.println("now check if httpclient dependency on commons-logging has been realized");
Class clss = Class.forName("org.apache.commons.logging.Log");
System.out.println("found logging class in classpath: "+clss);
}
}

View File

@ -0,0 +1,11 @@
<ivy-module version="1.0">
<info
organisation="apache"
module="commons-httpclient"
revision="2.0.2"
status="release"
publication="20041010174300"/>
<dependencies>
<dependency name="commons-logging" rev="1.0.4" conf="default"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,58 @@
<project name="hello-ivy" default="run" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<!-- some variables used -->
<property name="lib.dir" value="lib" />
<property name="build.dir" value="build" />
<property name="src.dir" value="src" />
<!-- paths used for compilation and run -->
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${build.dir}" />
</path>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" description="--> retreive dependencies with ivy">
<ivy:retrieve/>
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: run
================================= -->
<target name="run" depends="resolve" description="--> compile and run the project">
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id" />
<java classpathref="run.path.id" classname="example.Hello"/>
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean the project">
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<exclude name="src/**" />
<exclude name="build.xml" />
<exclude name="ivy.xml" />
</fileset>
</delete>
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<delete dir="${user.home}/.ivy-cache"/>
</target>
</project>

View File

@ -0,0 +1,6 @@
<ivy-module version="1.0">
<info organisation="jayasoft" module="hello-ivy"/>
<dependencies>
<dependency org="apache" name="commons-lang" rev="2.0"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,19 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package example;
import org.apache.commons.lang.WordUtils;
/**
* Simple example world to show how easy it is to retreive libs with ivy !!!
*/
public class Hello {
public static void main(String[] args) {
String message = "hello ivy !";
System.out.println("standard message : " + message);
System.out.println("capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message));
}
}

View File

@ -0,0 +1,62 @@
<project name="hello-ivy" default="run" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<!-- some variables used -->
<property name="lib.dir" value="lib" />
<property name="build.dir" value="build" />
<property name="src.dir" value="src" />
<!-- paths used for compilation and run -->
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${build.dir}" />
</path>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" description="--> retreive dependencies with ivy">
<ivy:retrieve/>
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: run
================================= -->
<target name="run" depends="resolve" description="--> compile and run the project">
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id" />
<property name="msg" value="hello ivy !"/>
<java classpathref="run.path.id" classname="example.Hello">
<arg value="-message"/>
<arg value="${msg}"/>
</java>
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean the project">
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<exclude name="src/**" />
<exclude name="build.xml" />
<exclude name="ivy.xml" />
</fileset>
</delete>
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<delete dir="${user.home}/.ivy-cache"/>
</target>
</project>

View File

@ -0,0 +1,7 @@
<ivy-module version="1.0">
<info organisation="jayasoft" module="ivyrep-example"/>
<dependencies>
<dependency org="apache" name="commons-lang" rev="2.0"/>
<dependency org="apache" name="commons-cli" rev="1.0"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,35 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package example;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.lang.WordUtils;
/**
* Simple example to show how easy it is to retrieve transitive libs with ivy !!!
*/
public class Hello {
public static void main(String[] args) throws Exception {
Option msg = OptionBuilder.withArgName( "msg" )
.hasArg()
.withDescription( "the message to capitalize" )
.create( "message" );
Options options = new Options();
options.addOption(msg);
CommandLineParser parser = new GnuParser();
CommandLine line = parser.parse( options, args );
String message = line.getOptionValue("message", "hello ivy !");
System.out.println("standard message : " + message);
System.out.println("capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message));
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* @author Hanin
*
*/
public abstract class AbstractArtifact implements Artifact {
public boolean equals(Object obj) {
if (!(obj instanceof Artifact)) {
return false;
}
Artifact art = (Artifact)obj;
return getModuleRevisionId().equals(art.getModuleRevisionId())
&& getPublicationDate()==null?true:getPublicationDate().equals(art.getPublicationDate())
&& getName().equals(art.getName())
&& getExt().equals(art.getExt())
&& getType().equals(art.getType());
}
public int hashCode() {
int hash = 33;
hash = hash * 17 + getModuleRevisionId().hashCode();
if (getPublicationDate() != null) {
hash = hash * 17 + getPublicationDate().hashCode();
}
hash = hash * 17 + getName().hashCode();
hash = hash * 17 + getExt().hashCode();
hash = hash * 17 + getType().hashCode();
return hash;
}
public String toString() {
return getModuleRevisionId()+"/"+getName()+"."+getExt()+"["+getType()+"]";
}
}

View File

@ -0,0 +1,35 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.Date;
/**
* @author x.hanin
*
*/
public interface Artifact {
/**
* Returns the resolved module revision id for this artifact
* @return
*/
ModuleRevisionId getModuleRevisionId();
/**
* Returns the resolved publication date for this artifact
* @return the resolved publication date
*/
Date getPublicationDate();
String getName();
String getType();
String getExt();
String[] getConfigurations();
/**
* @return the id of the artifact
*/
ArtifactRevisionId getId();
}

View File

@ -0,0 +1,77 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* Identifies an artifact in a module, without revision information
*/
public class ArtifactId {
private ModuleId _mid;
private String _name;
private String _type;
private String _ext;
/**
* @param mid
* @param name
* @param type
*/
public ArtifactId(ModuleId mid, String name, String type, String ext) {
_mid = mid;
_name = name;
_type = type;
_ext = ext;
}
public boolean equals(Object obj) {
if (! (obj instanceof ArtifactId)) {
return false;
}
ArtifactId aid = (ArtifactId)obj;
return getModuleId().equals(aid.getModuleId())
&& getName().equals(aid.getName())
&& getExt().equals(aid.getExt())
&& getType().equals(aid.getType());
}
public int hashCode() {
int hash = 17;
hash += getModuleId().hashCode() * 37;
hash += getName().hashCode() * 37;
hash += getType().hashCode() * 37;
return hash;
}
public String toString() {
return getModuleId()+" "+getName()+"."+getType();
}
/**
* @return Returns the module id.
*/
public ModuleId getModuleId() {
return _mid;
}
/**
* @return Returns the name.
*/
public String getName() {
return _name;
}
/**
* @return Returns the type.
*/
public String getType() {
return _type;
}
/**
* @return Returns the ext.
*/
public String getExt() {
return _ext;
}
}

View File

@ -0,0 +1,11 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
public interface ArtifactInfo {
String getRevision();
long getLastModified();
}

View File

@ -0,0 +1,79 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* identifies an artifact in a particular module revision
*/
public class ArtifactRevisionId {
public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type, String ext) {
return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, type, ext), mrid);
}
private ArtifactId _artifactId;
private ModuleRevisionId _mrid;
/**
* @param revision
* @param artifactId
*/
public ArtifactRevisionId(ArtifactId artifactId, ModuleRevisionId mrid) {
_artifactId = artifactId;
_mrid = mrid;
}
public boolean equals(Object obj) {
if (! (obj instanceof ArtifactRevisionId)) {
return false;
}
ArtifactRevisionId arid = (ArtifactRevisionId)obj;
return getArtifactId().equals(arid.getArtifactId())
&& getModuleRevisionId().equals(arid.getModuleRevisionId());
}
public int hashCode() {
int hash = 17;
hash += getArtifactId().hashCode() * 37;
hash += getModuleRevisionId().hashCode() * 37;
return hash;
}
public String toString() {
return getModuleRevisionId()+" "+getName()+"."+getType();
}
/**
* @return Returns the artifactId.
*/
public ArtifactId getArtifactId() {
return _artifactId;
}
public ModuleRevisionId getModuleRevisionId() {
return _mrid;
}
public String getName() {
return _artifactId.getName();
}
public String getType() {
return _artifactId.getType();
}
public String getExt() {
return _artifactId.getExt();
}
/**
* @return Returns the revision.
*/
public String getRevision() {
return _mrid.getRevision();
}
}

View File

@ -0,0 +1,109 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* Represents a module configuration
*/
public class Configuration {
public static class Visibility {
public static Visibility PUBLIC = new Visibility("public");
public static Visibility PRIVATE = new Visibility("private");
public static Visibility getVisibility(String name) {
if ("private".equals(name)) {
return PRIVATE;
} else if ("public".equals(name)) {
return PUBLIC;
} else {
throw new IllegalArgumentException("unknwon visibility "+name);
}
}
private String _name;
private Visibility(String name) {
_name = name;
}
}
private String _name;
private String _description;
private String[] _extends;
private Visibility _visibility;
/**
* @param name
* @param visibility
* @param description
* @param ext
*/
public Configuration(String name, Visibility visibility,
String description, String[] ext) {
if (name == null) {
throw new NullPointerException("null configuration name not allowed");
}
if (visibility == null) {
throw new NullPointerException("null visibility not allowed");
}
_name = name;
_visibility = visibility;
_description = description;
if (ext == null) {
_extends = new String[0];
} else {
_extends = new String[ext.length];
for (int i = 0; i < ext.length; i++) {
_extends[i] = ext[i].trim();
}
}
}
/**
* @param name
*/
public Configuration(String name) {
this(name, Visibility.PUBLIC, null, null);
}
/**
* @return Returns the description. It may be null.
*/
public String getDescription() {
return _description;
}
/**
* @return Returns the extends. May be empty, but never null.
*/
public String[] getExtends() {
return _extends;
}
/**
* @return Returns the name. Never null;
*/
public String getName() {
return _name;
}
/**
* @return Returns the visibility. Never null.
*/
public Visibility getVisibility() {
return _visibility;
}
public String toString() {
return _name;
}
public boolean equals(Object obj) {
if (! (obj instanceof Configuration)) {
return false;
}
return ((Configuration)obj).getName().equals(getName());
}
public int hashCode() {
return getName().hashCode();
}
}

View File

@ -0,0 +1,22 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.Collection;
public interface ConflictManager {
/**
* Resolves the eventual conflicts found in the given collection of IvyNode.
* This method return a Collection of IvyNode which have not been evicted.
* The returned collection must contain at least one IvyNode.
* The given conflicts Collection contains at least two IvyNode.
* @param parent the ivy node parent for which the conflict is to be resolved
* @param conflicts the collection of IvyNode to check for conflicts
* @return a Collection of IvyNode which have not been evicted
*/
Collection resolveConflicts(IvyNode parent, Collection conflicts);
String getName();
}

View File

@ -0,0 +1,60 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.Date;
/**
* @author Hanin
*
*/
public class DefaultArtifact extends AbstractArtifact {
Date _publicationDate;
ArtifactRevisionId _arid;
public DefaultArtifact(ModuleRevisionId mrid, Date publicationDate, String name, String type, String ext) {
if (mrid == null) {
throw new NullPointerException("null mrid not allowed");
}
if (publicationDate == null) {
throw new NullPointerException("null publication date not allowed");
}
if (name == null) {
throw new NullPointerException("null name not allowed");
}
if (type == null) {
throw new NullPointerException("null type not allowed");
}
if (ext == null) {
throw new NullPointerException("null ext not allowed");
}
_publicationDate = publicationDate;
_arid = ArtifactRevisionId.newInstance(mrid, name, type, ext);
}
public ModuleRevisionId getModuleRevisionId() {
return _arid.getModuleRevisionId();
}
public String getName() {
return _arid.getName();
}
public Date getPublicationDate() {
return _publicationDate;
}
public String getType() {
return _arid.getType();
}
public String getExt() {
return _arid.getExt();
}
public ArtifactRevisionId getId() {
return _arid;
}
public String[] getConfigurations() {
return new String[0];
}
}

View File

@ -0,0 +1,92 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.ArrayList;
import java.util.Collection;
/**
* TODO write javadoc
*/
public class DefaultDependencyArtifactDescriptor implements DependencyArtifactDescriptor {
private DefaultDependencyDescriptor _dd;
private ArtifactId _id;
private Collection _confs = new ArrayList();
private boolean _includes;
/**
* @param dd
* @param name
* @param type
*/
public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd,
String name, String type, String ext, boolean includes) {
if (dd == null) {
throw new NullPointerException("dependency descriptor must not be null");
}
if (name == null) {
throw new NullPointerException("name must not be null");
}
if (type == null) {
throw new NullPointerException("type must not be null");
}
_dd = dd;
_id = new ArtifactId(dd.getDependencyId(), name, type, ext);
_includes = includes;
}
public boolean equals(Object obj) {
if (!(obj instanceof DependencyArtifactDescriptor)) {
return false;
}
DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)obj;
return getId().equals(dad.getId());
}
public int hashCode() {
return getId().hashCode();
}
/**
* Add a configuration for this artifact (includes or excludes depending on this type dependency artifact descriptor).
* This method also updates the corresponding dependency descriptor
* @param conf
*/
public void addConfiguration(String conf) {
_confs.add(conf);
if (_includes) {
_dd.addDependencyArtifactIncludes(conf, this);
} else {
_dd.addDependencyArtifactExcludes(conf, this);
}
}
public DependencyDescriptor getDependency() {
return _dd;
}
public ArtifactId getId() {
return _id;
}
public String getName() {
return _id.getName();
}
public String getType() {
return _id.getType();
}
public String getExt() {
return _id.getExt();
}
public String[] getConfigurations() {
return (String[])_confs.toArray(new String[_confs.size()]);
}
}

View File

@ -0,0 +1,192 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* This class can be used as the default implementation for DependencyDescriptor.
* It implements required methods and enables to fill dependency information
* with the addDependencyConfiguration method.
*
* @author Xavier Hanin
*
*/
public class DefaultDependencyDescriptor implements DependencyDescriptor {
private ModuleRevisionId _revId;
private Map _confs = new HashMap();
private Map _artifactsIncludes = new HashMap(); // Map (String masterConf -> Collection(DependencyArtifactDescriptor))
private Map _artifactsExcludes = new HashMap(); // Map (String masterConf -> Collection(DependencyArtifactDescriptor))
private Set _extends = new HashSet();
/**
* Used to indicate that this revision must be used in case of conflicts, independently
* of conflicts manager
*/
private boolean _force;
private ModuleRevisionId _parentId;
public DefaultDependencyDescriptor(ModuleDescriptor md, ModuleRevisionId mrid, boolean force) {
_parentId = md.getModuleRevisionId();
_revId = mrid;
_force = force;
}
public DefaultDependencyDescriptor(ModuleRevisionId mrid, boolean force) {
_revId = mrid;
_force = force;
}
public ModuleId getDependencyId() {
return getDependencyRevisionId().getModuleId();
}
public ModuleRevisionId getDependencyRevisionId() {
return _revId;
}
public String[] getModuleConfigurations() {
// if (_confs.isEmpty()) { // if no conf has been defined then all confs are required in all confs
// return new String[] {"*"};
// }
return (String[]) _confs.keySet().toArray(new String[_confs.keySet().size()]);
}
public String[] getDependencyConfigurations(String moduleConfiguration) {
// if (_confs.isEmpty()) { // if no conf has been defined then all confs are required in all confs
// return new String[] {"*"};
// }
List confs = (List)_confs.get(moduleConfiguration);
List defConfs = (List)_confs.get("*");
List ret = new ArrayList();
if (confs != null) {
ret.addAll(confs);
}
if (defConfs != null) {
ret.addAll(defConfs);
}
return (String[])ret.toArray(new String[ret.size()]);
}
public String[] getDependencyConfigurations(String[] moduleConfigurations) {
Set confs = new HashSet();
for (int i = 0; i < moduleConfigurations.length; i++) {
confs.addAll(Arrays.asList(getDependencyConfigurations(moduleConfigurations[i])));
}
if (confs.contains("*")) {
return new String[] {"*"};
}
return (String[]) confs.toArray(new String[confs.size()]);
}
public DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String moduleConfiguration) {
return getDependencyArtifacts(moduleConfiguration, _artifactsIncludes);
}
public DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String moduleConfiguration) {
return getDependencyArtifacts(moduleConfiguration, _artifactsExcludes);
}
private DependencyArtifactDescriptor[] getDependencyArtifacts(String moduleConfiguration, Map artifactsMap) {
if (artifactsMap.isEmpty()) {
return new DependencyArtifactDescriptor[0];
}
Collection artifacts = (Collection)artifactsMap.get(moduleConfiguration);
Collection defArtifacts = (Collection)artifactsMap.get("*");
Set ret = new HashSet();
if (artifacts != null) {
ret.addAll(artifacts);
}
if (defArtifacts != null) {
ret.addAll(defArtifacts);
}
return (DependencyArtifactDescriptor[])ret.toArray(new DependencyArtifactDescriptor[ret.size()]);
}
public DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String[] moduleConfigurations) {
Set artifacts = new HashSet();
for (int i = 0; i < moduleConfigurations.length; i++) {
artifacts.addAll(Arrays.asList(getDependencyArtifactsIncludes(moduleConfigurations[i])));
}
return (DependencyArtifactDescriptor[]) artifacts.toArray(new DependencyArtifactDescriptor[artifacts.size()]);
}
public DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String[] moduleConfigurations) {
Set artifacts = new HashSet();
for (int i = 0; i < moduleConfigurations.length; i++) {
artifacts.addAll(Arrays.asList(getDependencyArtifactsExcludes(moduleConfigurations[i])));
}
return (DependencyArtifactDescriptor[]) artifacts.toArray(new DependencyArtifactDescriptor[artifacts.size()]);
}
public DependencyArtifactDescriptor[] getAllDependencyArtifactsIncludes() {
return getAllDependencyArtifacts(_artifactsIncludes);
}
public DependencyArtifactDescriptor[] getAllDependencyArtifactsExcludes() {
return getAllDependencyArtifacts(_artifactsExcludes);
}
private DependencyArtifactDescriptor[] getAllDependencyArtifacts(Map artifactsMap) {
Set ret = new HashSet();
for (Iterator it = artifactsMap.values().iterator(); it.hasNext();) {
Collection artifacts = (Collection)it.next();
ret.addAll(artifacts);
}
return (DependencyArtifactDescriptor[])ret.toArray(new DependencyArtifactDescriptor[ret.size()]);
}
public void addDependencyConfiguration(String masterConf, String depConf) {
List confs = (List)_confs.get(masterConf);
if (confs == null) {
confs = new ArrayList();
_confs.put(masterConf, confs);
}
confs.add(depConf);
}
public void addDependencyArtifactIncludes(String masterConf, DependencyArtifactDescriptor dad) {
addDependencyArtifacts(masterConf, dad, _artifactsIncludes);
}
public void addDependencyArtifactExcludes(String masterConf, DependencyArtifactDescriptor dad) {
addDependencyArtifacts(masterConf, dad, _artifactsExcludes);
}
private void addDependencyArtifacts(String masterConf, DependencyArtifactDescriptor dad, Map artifactsMap) {
Collection artifacts = (Collection)artifactsMap.get(masterConf);
if (artifacts == null) {
artifacts = new ArrayList();
artifactsMap.put(masterConf, artifacts);
}
artifacts.add(dad);
}
public void addExtends(String conf) {
_extends.add(conf);
}
public String toString() {
return "dependency: "+_revId+" "+_confs;
}
public boolean isForce() {
return _force;
}
public ModuleRevisionId getParentRevisionId() {
return _parentId;
}
}

View File

@ -0,0 +1,274 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
* @author X.Hanin
*
*/
public class DefaultModuleDescriptor implements ModuleDescriptor {
public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid) {
return newDefaultInstance(mrid, null);
}
public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid, DependencyArtifactDescriptor[] artifacts) {
DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(mrid, "release", null, true);
moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
if (artifacts != null && artifacts.length > 0) {
for (int i = 0; i < artifacts.length; i++) {
moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, artifacts[i].getName(), artifacts[i].getType(), artifacts[i].getExt()));
}
} else {
moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, mrid.getName(), "jar", "jar"));
}
moduleDescriptor.setLastModified(System.currentTimeMillis());
return moduleDescriptor;
}
private ModuleRevisionId _revId;
private ModuleRevisionId _resolvedRevId;
private String _status;
private Date _publicationDate;
private Date _resolvedPublicationDate;
private List _dependencies = new ArrayList();
private Map _configurations = new HashMap(); // Map(String conf -> Configuration)
private Map _artifacts = new HashMap(); // Map (String conf -> Collection(Artifact))
private String _resolverName;
private boolean _isDefault = false;
private Map _conflictManagers = new LinkedHashMap(); // Map (ModuleId -> )
private List _licenses = new ArrayList(); // List(License)
private String _homePage;
private long _lastModified = 0;
public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate) {
this(id, status, pubDate, false);
}
public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate, boolean isDefault) {
if (id == null) {
throw new NullPointerException("null module reivsion id not allowed");
}
_revId = id;
_resolvedRevId = id;
_status = status;
_publicationDate = pubDate;
_resolvedPublicationDate = _publicationDate==null?new Date():_publicationDate;
_isDefault = isDefault;
}
/**
* IMPORTANT : at least call setModuleRevisionId and setResolvedPublicationDate
* with instances created by this constructor !
*
*/
public DefaultModuleDescriptor() {
}
public boolean isDefault() {
return _isDefault;
}
public void setPublicationDate(Date publicationDate) {
_publicationDate = publicationDate;
if (_resolvedPublicationDate == null) {
_resolvedPublicationDate = _publicationDate==null?new Date():_publicationDate;
}
}
public Date getPublicationDate() {
return _publicationDate;
}
public void setResolvedPublicationDate(Date publicationDate) {
if (publicationDate == null) {
throw new NullPointerException("null publication date not allowed");
}
_resolvedPublicationDate = publicationDate;
}
public Date getResolvedPublicationDate() {
return _resolvedPublicationDate;
}
public void setModuleRevisionId(ModuleRevisionId revId) {
if (revId == null) {
throw new NullPointerException("null module revision id not allowed");
}
_revId = revId;
if (_resolvedRevId == null) {
_resolvedRevId = _revId;
}
}
public void setResolvedModuleRevisionId(ModuleRevisionId revId) {
_resolvedRevId = revId;
}
public void setStatus(String status) {
_status = status;
}
public void addDependency(DependencyDescriptor dependency) {
_dependencies.add(dependency);
}
public void addConfiguration(Configuration conf) {
_configurations.put(conf.getName(), conf);
}
/**
* Artifact configurations are not used since added artifact may not be
* entirely completed, so its configurations data may not be accurate
* @param conf
* @param artifact
*/
public void addArtifact(String conf, Artifact artifact) {
Collection artifacts = (Collection)_artifacts.get(conf);
if (artifacts == null) {
artifacts = new ArrayList();
_artifacts.put(conf, artifacts);
}
artifacts.add(artifact);
}
public ModuleRevisionId getModuleRevisionId() {
return _revId;
}
public ModuleRevisionId getResolvedModuleRevisionId() {
return _resolvedRevId;
}
public String getStatus() {
return _status;
}
public Configuration[] getConfigurations() {
return (Configuration[])_configurations.values().toArray(new Configuration[_configurations.size()]);
}
public String[] getConfigurationsNames() {
return (String[])_configurations.keySet().toArray(new String[_configurations.size()]);
}
/**
* Returns the configuration object with the given name in the current module descriptor, null
* if not found.
*/
public Configuration getConfiguration(String confName) {
return (Configuration)_configurations.get(confName);
}
public Artifact[] getArtifacts(String conf) {
Collection artifacts = (Collection)_artifacts.get(conf);
if (artifacts == null) {
return new Artifact[0];
} else {
return (Artifact[])artifacts.toArray(new Artifact[artifacts.size()]);
}
}
public Artifact[] getAllArtifacts() {
Collection ret = new ArrayList();
for (Iterator iter = _artifacts.keySet().iterator(); iter.hasNext();) {
String conf = (String)iter.next();
ret.addAll((Collection)_artifacts.get(conf));
}
return (Artifact[])ret.toArray(new Artifact[ret.size()]);
}
public DependencyDescriptor[] getDependencies() {
return (DependencyDescriptor[])_dependencies.toArray(new DependencyDescriptor[_dependencies.size()]);
}
public boolean dependsOn(ModuleDescriptor md) {
for (Iterator iter = _dependencies.iterator(); iter.hasNext();) {
DependencyDescriptor dd = (DependencyDescriptor)iter.next();
if (dd.getDependencyId().equals(md.getModuleRevisionId().getModuleId())) {
if (md.getResolvedModuleRevisionId().getRevision() == null) {
return true;
} else if (dd.getDependencyRevisionId().acceptRevision(md.getResolvedModuleRevisionId().getRevision())) {
return true;
}
}
}
return false;
}
public String getResolverName() {
return _resolverName;
}
public void setResolverName(String resolverName) {
_resolverName = resolverName;
}
public String toString() {
return "module: "+_revId+" status="+_status+" publication="+_publicationDate+" configurations="+_configurations+" artifacts="+_artifacts+" dependencies="+_dependencies;
}
public void setDefault(boolean b) {
_isDefault = b;
}
/**
* regular expressions as explained in Pattern class may be used in ModuleId
* organisation and name
*
* @param moduleId
* @param resolverName
*/
public void addConflictManager(ModuleId moduleId, ConflictManager manager) {
_conflictManagers.put(moduleId, manager);
}
public ConflictManager getConflictManager(ModuleId moduleId) {
ConflictManager cm = (ConflictManager)_conflictManagers.get(moduleId);
if (cm != null) {
return cm;
}
for (Iterator iter = _conflictManagers.keySet().iterator(); iter.hasNext();) {
ModuleId mid = (ModuleId)iter.next();
if (Pattern.compile(mid.getOrganisation()).matcher(moduleId.getOrganisation()).matches()
&& Pattern.compile(mid.getName()).matcher(moduleId.getName()).matches()) {
return (ConflictManager)_conflictManagers.get(mid);
}
}
return null;
}
public void addLicense(License license) {
_licenses.add(license);
}
public License[] getLicenses() {
return (License[])_licenses.toArray(new License[_licenses.size()]);
}
public String getHomePage() {
return _homePage;
}
public void setHomePage(String homePage) {
_homePage = homePage;
}
public long getLastModified() {
return _lastModified;
}
public void setLastModified(long lastModified) {
_lastModified = lastModified;
}
}

View File

@ -0,0 +1,67 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.Date;
/**
* @author x.hanin
*
*/
public class DefaultModuleRevision implements ResolvedModuleRevision {
private DependencyResolver _resolver;
private ModuleDescriptor _descriptor;
private boolean _isDownloaded;
private boolean _isSearched;
public DefaultModuleRevision(DependencyResolver resolver, ModuleDescriptor descriptor, boolean searched, boolean downloaded) {
_resolver = resolver;
_descriptor = descriptor;
_isSearched = searched;
_isDownloaded = downloaded;
}
public DependencyResolver getResolver() {
return _resolver;
}
public ModuleDescriptor getDescriptor() {
return _descriptor;
}
public ModuleRevisionId getId() {
return _descriptor.getResolvedModuleRevisionId();
}
public Date getPublicationDate() {
return _descriptor.getResolvedPublicationDate();
}
public boolean equals(Object obj) {
if (! (obj instanceof ResolvedModuleRevision)) {
return false;
}
return ((ResolvedModuleRevision)obj).getId().equals(getId());
}
public int hashCode() {
return getId().hashCode();
}
public String toString() {
return getId().toString();
}
public boolean isDownloaded() {
return _isDownloaded;
}
public boolean isSearched() {
return _isSearched;
}
}

View File

@ -0,0 +1,13 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
public final class DefaultPublishingDRResolver implements PublishingDependencyRevisionResolver {
public String resolve(ModuleDescriptor published, String publishedStatus, ModuleDescriptor dependency) {
return dependency.getResolvedModuleRevisionId().getRevision();
}
}

View File

@ -0,0 +1,46 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* This describes an artifact that is asked for a dependency.
*
* It is used to resctrict the artifacts asked for a dependency, or describe them
* when there is no ivy file.
*/
public interface DependencyArtifactDescriptor {
/**
* Returns the dependency descriptor in which this artifact is asked
* @return
*/
public DependencyDescriptor getDependency();
/**
* Returns the id of the described artifact, without revision information
* @return
*/
public ArtifactId getId();
/**
* Returns the name of the artifact asked
* @return
*/
public String getName();
/**
* Returns the type of the artifact asked
* @return
*/
public String getType();
/**
* Returns the ext of the artifact asked
* @return
*/
public String getExt();
/**
* Returns the configurations of the module in which the artifact is asked
* @return an array of configuration names in which the artifact is asked
*/
public String[] getConfigurations();
}

View File

@ -0,0 +1,33 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* @author x.hanin
*
*/
public interface DependencyDescriptor {
ModuleId getDependencyId();
/**
* Used to indicate that this revision must be used in case of conflicts, independently
* of conflicts manager. This only works for direct dependencies, and not transitive ones.
* @return true if this dependency should be used, false if conflicts manager
* can do its work.
*/
boolean isForce();
ModuleRevisionId getParentRevisionId();
ModuleRevisionId getDependencyRevisionId();
String[] getModuleConfigurations();
String[] getDependencyConfigurations(String moduleConfiguration);
String[] getDependencyConfigurations(String[] moduleConfigurations);
DependencyArtifactDescriptor[] getAllDependencyArtifactsIncludes();
DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String moduleConfigurations);
DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String[] moduleConfigurations);
DependencyArtifactDescriptor[] getAllDependencyArtifactsExcludes();
DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String moduleConfigurations);
DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String[] moduleConfigurations);
}

View File

@ -0,0 +1,60 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import fr.jayasoft.ivy.report.DownloadReport;
import fr.jayasoft.ivy.resolver.ModuleEntry;
import fr.jayasoft.ivy.resolver.OrganisationEntry;
import fr.jayasoft.ivy.resolver.RevisionEntry;
/**
* @author x.hanin
*
*/
public interface DependencyResolver {
String getName();
/**
* Should only be used by configurator
* @param name the new name of the resolver
*/
void setName(String name);
/**
* Resolve a module by id, getting its module descriptor and
* resolving the revision if it's a latest one (i.e. a revision
* uniquely identifying the revision of a module in the current environment -
* If this revision is not able to identify uniquelely the revision of the module
* outside of the current environment, then the resolved revision must begin by ##)
* @throws ParseException
*/
ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException;
DownloadReport download(Artifact[] artifacts, Ivy ivy, File cache);
boolean exists(Artifact artifact);
void publish(Artifact artifact, File src) throws IOException;
/**
* Reports last resolve failure as Messages
*/
void reportFailure();
/**
* Reports last artifact download failure as Messages
* @param art
*/
void reportFailure(Artifact art);
// listing methods, enable to know what is available from this resolver
// the listing methods must only list entries directly
// available from them, no recursion is needed as long as sub resolvers
// are registered in ivy too.
OrganisationEntry[] listOrganisations();
ModuleEntry[] listModules(OrganisationEntry org);
RevisionEntry[] listRevisions(ModuleEntry module);
void dumpConfig();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
public interface IvyAware {
void setIvy(Ivy ivy);
}

View File

@ -0,0 +1,974 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import fr.jayasoft.ivy.util.Message;
public class IvyNode {
public static class EvictionData {
private IvyNode _node;
private ConflictManager _conflictManager;
private Collection _selected;
private String _rootModuleConf;
public EvictionData(String rootModuleConf, IvyNode node, ConflictManager conflictManager, Collection selected) {
_rootModuleConf = rootModuleConf;
_node = node;
_conflictManager = conflictManager;
_selected = selected;
}
public String toString() {
return _selected + " in "+ _node+" ("+_conflictManager+") ["+_rootModuleConf+"]";
}
public ConflictManager getConflictManager() {
return _conflictManager;
}
public IvyNode getNode() {
return _node;
}
public Collection getSelected() {
return _selected;
}
public String getRootModuleConf() {
return _rootModuleConf;
}
}
public static class Caller {
private ModuleRevisionId _mrid;
private Map _confs = new HashMap(); // Map (String callerConf -> String[] dependencyConfs)
private ModuleRevisionId _askedDependencyId;
public Caller(ModuleRevisionId mrid, ModuleRevisionId askedDependencyId) {
_mrid = mrid;
_askedDependencyId = askedDependencyId;
}
public void addConfiguration(String callerConf, String[] dependencyConfs) {
String[] prevDepConfs = (String[])_confs.get(callerConf);
if (prevDepConfs != null) {
Set newDepConfs = new HashSet(Arrays.asList(prevDepConfs));
newDepConfs.addAll(Arrays.asList(dependencyConfs));
_confs.put(callerConf, (String[])newDepConfs.toArray(new String[newDepConfs.size()]));
} else {
_confs.put(callerConf, dependencyConfs);
}
}
public String[] getCallerConfigurations() {
return (String[])_confs.keySet().toArray(new String[_confs.keySet().size()]);
}
public ModuleRevisionId getModuleRevisionId() {
return _mrid;
}
public boolean equals(Object obj) {
if (! (obj instanceof Caller)) {
return false;
}
Caller other = (Caller)obj;
return other._confs.equals(_confs)
&& _mrid.equals(other._mrid);
}
public int hashCode() {
int hash = 31;
hash = hash * 13 + _confs.hashCode();
hash = hash * 13 + _mrid.hashCode();
return hash;
}
public String toString() {
return _mrid.toString();
}
public ModuleRevisionId getAskedDependencyId() {
return _askedDependencyId;
}
}
private static final class NodeConf {
private IvyNode _node;
private String _conf;
public NodeConf(IvyNode node, String conf) {
_node = node;
_conf = conf;
}
public final String getConf() {
return _conf;
}
public final IvyNode getNode() {
return _node;
}
public boolean equals(Object obj) {
if (!(obj instanceof NodeConf)) {
return false;
}
return getNode().equals(((NodeConf)obj).getNode())
&& getConf().equals(((NodeConf)obj).getConf());
}
public int hashCode() {
int hash = 33;
hash += getNode().hashCode() * 17;
hash += getConf().hashCode() * 17;
return hash;
}
}
private static final class ModuleIdConf {
private ModuleId _moduleId;
private String _conf;
public ModuleIdConf(ModuleId mid, String conf) {
_moduleId = mid;
_conf = conf;
}
public final String getConf() {
return _conf;
}
public final ModuleId getModuleId() {
return _moduleId;
}
public boolean equals(Object obj) {
if (!(obj instanceof ModuleIdConf)) {
return false;
}
return getModuleId().equals(((ModuleIdConf)obj).getModuleId())
&& getConf().equals(((ModuleIdConf)obj).getConf());
}
public int hashCode() {
int hash = 33;
hash += getModuleId().hashCode() * 17;
hash += getConf().hashCode() * 17;
return hash;
}
}
private ModuleRevisionId _id; // id as requested, i.e. may be with latest rev
/**
* Represents the current parent of the node during ivy visit
* of dependency graph.
* Use callers on Dependency to know all the callers
* of a dependency
*/
private IvyNode _parent = null;
private String _parentConf = null;
private String _rootModuleConf;
private Map _selected = new HashMap(); // Map (ModuleIdConf -> Set(Node))
private Map _evicted = new HashMap(); // Map (root module conf -> EvictionData)
// Map (String rootModuleConf -> Map (ModuleRevisionId -> Caller)): key in second map is used to easily get a caller by its mrid
private Map _callersByRootConf = new HashMap();
// Map (String rootConfName -> Set(String confName))
// used to know which configurations of the dependency are required by root
// module configuration
private Map _rootModuleConfs = new HashMap();
// Map (String rootModuleConf -> Set(DependencyArtifactDescriptor))
private Map _dependencyArtifactsIncludes = new HashMap();
// Map (String rootModuleConf -> Set(DependencyArtifactDescriptor))
private Map _dependencyArtifactsExcludes = new HashMap();
// shared data
private ResolveData _data;
private Collection _confsToFetch = new HashSet();
private Collection _fetchedConfigurations = new HashSet();
// set only when node has been built from DependencyDescriptor
private DependencyDescriptor _dd;
// Set when data has been loaded only
private ModuleDescriptor _md;
private ResolvedModuleRevision _module;
private Exception _problem = null;
private boolean _downloaded = false;
private boolean _searched = false;
private Map _requiredConfs = new HashMap(); // Map (NodeConf in -> Set(String conf))
public IvyNode(ResolveData data, DependencyDescriptor dd) {
_id = dd.getDependencyRevisionId();
_dd = dd;
init(data, true);
}
public IvyNode(ResolveData data, ModuleDescriptor md, String conf) {
_id = md.getModuleRevisionId();
_md = md;
_confsToFetch.add(conf);
// we do not register nodes created from ModuleDescriptor, cause they are
// the root of resolve
init(data, false);
}
private void init(ResolveData data, boolean register) {
_data = data;
if (register) {
_data.register(this);
}
}
public ConflictManager getConflictManager(ModuleId mid) {
if (_md == null) {
throw new IllegalStateException("impossible to get conflict manager when data has not been loaded");
}
ConflictManager cm = _md.getConflictManager(mid);
return cm == null ? _data.getIvy().getDefaultConflictManager() : cm;
}
public Collection getResolvedNodes(ModuleId mid, String rootModuleConf) {
Collection resolved = (Collection)_selected.get(new ModuleIdConf(mid, rootModuleConf));
Set ret = new HashSet();
if (resolved != null) {
for (Iterator iter = resolved.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode)iter.next();
ret.add(node.getRealNode());
}
}
return ret;
}
public Collection getResolvedRevisions(ModuleId mid, String rootModuleConf) {
Collection resolved = (Collection)_selected.get(new ModuleIdConf(mid, rootModuleConf));
if (resolved == null) {
return new HashSet();
} else {
Collection ret = new HashSet();
for (Iterator iter = resolved.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode)iter.next();
ret.add(node.getRealNode().getId());
}
return ret;
}
}
public void setResolvedNodes(ModuleId moduleId, String rootModuleConf, Collection resolved) {
_selected.put(new ModuleIdConf(moduleId, rootModuleConf), new HashSet(resolved));
}
public boolean isEvicted(String rootModuleConf) {
cleanEvicted();
return _evicted.containsKey(rootModuleConf);
}
private void cleanEvicted() {
// check if it was evicted by a node that we are now the real node for
for (Iterator iter = _evicted.keySet().iterator(); iter.hasNext();) {
String rootModuleConf = (String)iter.next();
EvictionData ed = (EvictionData)_evicted.get(rootModuleConf);
Collection sel = ed.getSelected();
for (Iterator iterator = sel.iterator(); iterator.hasNext();) {
IvyNode n = (IvyNode)iterator.next();
if (n.getRealNode().equals(this)) {
// yes, we are the real node for a selected one !
// we are no more evicted in this conf !
iter.remove();
}
}
}
}
public void markSelected(String rootModuleConf) {
_evicted.remove(rootModuleConf);
}
public void markEvicted(String rootModuleConf, IvyNode node, ConflictManager conflictManager, Collection resolved) {
_evicted.put(rootModuleConf, new EvictionData(rootModuleConf, node, conflictManager, resolved));
if (!_rootModuleConfs.keySet().contains(rootModuleConf)) {
_rootModuleConfs.put(rootModuleConf, null);
}
// bug 105: update selected data with evicted one
for (Iterator iter = resolved.iterator(); iter.hasNext();) {
IvyNode selected = (IvyNode)iter.next();
selected.updateDataFrom(this, rootModuleConf);
}
}
private void updateDataFrom(IvyNode node, String rootModuleConf) {
// update callers
Map nodecallers = (Map)node._callersByRootConf.get(rootModuleConf);
if (nodecallers != null) {
Map thiscallers = (Map)_callersByRootConf.get(rootModuleConf);
if (thiscallers == null) {
thiscallers = new HashMap();
_callersByRootConf.put(rootModuleConf, thiscallers);
}
for (Iterator iter = nodecallers.values().iterator(); iter.hasNext();) {
Caller caller = (Caller)iter.next();
if (!thiscallers.containsKey(caller.getModuleRevisionId())) {
thiscallers.put(caller.getModuleRevisionId(), caller);
}
}
}
// update requiredConfs
updateMapOfSet(node._requiredConfs, _requiredConfs);
// update rootModuleConfs
updateMapOfSetForKey(node._rootModuleConfs, _rootModuleConfs, rootModuleConf);
// update dependencyArtifactsIncludes
updateMapOfSetForKey(node._dependencyArtifactsIncludes, _dependencyArtifactsIncludes, rootModuleConf);
// update dependencyArtifactsExcludes
updateMapOfSetForKey(node._dependencyArtifactsExcludes, _dependencyArtifactsExcludes, rootModuleConf);
// update confsToFetch
updateConfsToFetch(node._fetchedConfigurations);
updateConfsToFetch(node._confsToFetch);
}
private void updateMapOfSet(Map from, Map to) {
for (Iterator iter = from.keySet().iterator(); iter.hasNext();) {
Object key = iter.next();
updateMapOfSetForKey(from, to, key);
}
}
private void updateMapOfSetForKey(Map from, Map to, Object key) {
Set set = (Set)from.get(key);
if (set != null) {
Set toupdate = (Set)to.get(key);
if (toupdate != null) {
toupdate.addAll(set);
} else {
to.put(key, new HashSet(set));
}
}
}
public EvictionData getEvictedData(String rootModuleConf) {
cleanEvicted();
return (EvictionData)_evicted.get(rootModuleConf);
}
public String[] getEvictedConfs() {
cleanEvicted();
return (String[])_evicted.keySet().toArray(new String[_evicted.keySet().size()]);
}
public boolean isCompletelyEvicted() {
cleanEvicted();
return _evicted.keySet().containsAll(_rootModuleConfs.keySet());
}
public Collection getAllEvictingNodes() {
Collection allEvictingNodes = new HashSet();
for (Iterator iter = _evicted.values().iterator(); iter.hasNext();) {
EvictionData ed = (EvictionData)iter.next();
allEvictingNodes.addAll(ed.getSelected());
}
return allEvictingNodes;
}
public IvyNode getParent() {
return _parent;
}
public void setParent(IvyNode parent) {
_parent = parent;
}
public String getParentConf() {
return _parentConf;
}
public void setParentConf(String parentConf) {
_parentConf = parentConf;
}
public boolean hasConfigurationsToLoad() {
return !_confsToFetch.isEmpty();
}
/**
* After the call node may be discarded. To avoid using discarded node, make sure
* to get the real node after the call
* IvyNode node = ...
* node.loadData();
* node = node.getRealNode();
* ...
*/
public boolean loadData(String conf) {
boolean loaded = _md != null;
if (!isEvicted(_rootModuleConf) && hasConfigurationsToLoad() && !hasProblem()) {
if (_md == null) {
DependencyResolver resolver = _data.getIvy().getResolver(getModuleId());
try {
Message.debug("\tusing "+resolver+" to resolve "+getId());
_module = resolver.getDependency(_dd, _data);
if (_module != null) {
if (!getId().isExactRevision()) {
IvyNode resolved = _data.getNode(_module.getId());
if (resolved != null) {
// exact revision has already been resolved
// => update it and discard this node
resolved._downloaded |= _module.isDownloaded();
resolved._searched |= _module.isSearched();
resolved.markSelected(_rootModuleConf);
resolved.updateDataFrom(this, _rootModuleConf);
resolved.loadData(conf);
if (_dd != null) {
resolved.addDependencyArtifactsIncludes(_rootModuleConf, _dd.getDependencyArtifactsIncludes(getParentConf()));
resolved.addDependencyArtifactsExcludes(_rootModuleConf, _dd.getDependencyArtifactsExcludes(getParentConf()));
}
_data.register(getId(), resolved); // this actually discards the node
return true;
}
}
_downloaded = _module.isDownloaded();
_searched = _module.isSearched();
} else {
Message.warn("\tmodule not found: "+getId());
resolver.reportFailure();
_problem = new RuntimeException("not found");
}
} catch (ParseException e) {
_problem = e;
}
// still not resolved, report error
if (_module == null) {
_data.getReport().addDependency(this);
return false;
} else {
loaded = true;
if (!getId().isExactRevision()) {
Message.info("\t["+_module.getId().getRevision()+"] "+getId());
}
_md = _module.getDescriptor();
// if the revision was a latest one (which has now be resolved)
// store also it to cache the result
if (!getId().isExactRevision()) {
_data.register(_module.getId(), this);
}
_confsToFetch.remove("*");
updateConfsToFetch(Arrays.asList(resolveSpecialConfigurations(getRequiredConfigurations(getParent(), getParentConf()), this)));
}
}
}
if (hasProblem()) {
_data.getReport().addDependency(this);
return loaded;
}
if ("*".equals(conf)) {
if (_md != null) {
_fetchedConfigurations.addAll(Arrays.asList(_md.getConfigurationsNames()));
_confsToFetch.clear();
addRootModuleConfigurations(_rootModuleConf, _md.getConfigurationsNames());
}
} else {
if (loaded) {
_fetchedConfigurations.add(conf);
_confsToFetch.remove(conf);
}
addRootModuleConfigurations(_rootModuleConf, new String[] {conf});
}
if (_dd != null) {
addDependencyArtifactsIncludes(_rootModuleConf, _dd.getDependencyArtifactsIncludes(getParentConf()));
addDependencyArtifactsExcludes(_rootModuleConf, _dd.getDependencyArtifactsExcludes(getParentConf()));
}
return loaded;
}
public IvyNode getRealNode() {
IvyNode node = _data.getNode(getId());
return node == null ? this : node;
}
public Collection getDependencies(String[] confs) {
if (_md == null) {
throw new IllegalStateException("impossible to get dependencies when data has not been loaded");
}
if (Arrays.asList(confs).contains("*")) {
confs = _md.getConfigurationsNames();
}
Collection deps = new HashSet();
for (int i = 0; i < confs.length; i++) {
deps.addAll(getDependencies(confs[i], false));
}
return deps;
}
public Collection getDependencies(String conf, boolean traverse) {
if (_md == null) {
throw new IllegalStateException("impossible to get dependencies when data has not been loaded");
}
DependencyDescriptor[] dds = _md.getDependencies();
Collection dependencies = new LinkedHashSet(); // it's important to respect dependencies order
for (int i = 0; i < dds.length; i++) {
DependencyDescriptor dd = dds[i];
String[] dependencyConfigurations = dd.getDependencyConfigurations(conf);
if (dependencyConfigurations.length == 0) {
// no configuration of the dependency is required for current confs :
// it is exactly the same as if there was no dependency at all on it
continue;
}
IvyNode depNode = _data.getNode(dd.getDependencyRevisionId());
if (depNode == null) {
depNode = new IvyNode(_data, dd);
} else if (depNode.hasProblem()) {
// dependency already tried to be resolved, but unsuccessfully
// nothing special to do
}
Collection confs = Arrays.asList(resolveSpecialConfigurations(dependencyConfigurations, depNode));
depNode.updateConfsToFetch(confs);
depNode.setRequiredConfs(this, conf, confs);
depNode.addCaller(_rootModuleConf, _md.getModuleRevisionId(), conf, dependencyConfigurations, dd.getDependencyRevisionId());
dependencies.add(depNode);
if (traverse) {
depNode.setParent(this);
depNode.setParentConf(conf);
depNode.setRootModuleConf(getRootModuleConf());
depNode._data = _data;
}
}
return dependencies;
}
public ModuleRevisionId getId() {
return _id;
}
public void updateConfsToFetch(Collection confs) {
_confsToFetch.addAll(confs);
_confsToFetch.removeAll(_fetchedConfigurations);
}
public ModuleId getModuleId() {
return _id.getModuleId();
}
/**
* resolve the '*' special configurations if necessary and possible
*/
private String[] resolveSpecialConfigurations(String[] dependencyConfigurations, IvyNode node) {
if (dependencyConfigurations.length == 1
&& "*".equals(dependencyConfigurations[0])
&& node != null
&& node.isLoaded()) {
return node.getDescriptor().getConfigurationsNames();
}
return dependencyConfigurations;
}
public boolean isLoaded() {
return _md != null;
}
public ModuleDescriptor getDescriptor() {
return _md;
}
/**
* returns the required configurations from the given node
* @param in
* @return
*/
public String[] getRequiredConfigurations(IvyNode in, String inConf) {
Collection req = (Collection)_requiredConfs.get(new NodeConf(in, inConf));
return req == null?new String[0]:(String[])req.toArray(new String[req.size()]);
}
/**
* returns all the current required configurations of the node
* @return
*/
public String[] getRequiredConfigurations() {
Collection required = new ArrayList(_confsToFetch.size() + _fetchedConfigurations.size());
required.addAll(_fetchedConfigurations);
required.addAll(_confsToFetch);
return (String[])required.toArray(new String[required.size()]);
}
private void setRequiredConfs(IvyNode parent, String parentConf, Collection confs) {
_requiredConfs.put(new NodeConf(parent, parentConf), new HashSet(confs));
}
public Configuration getConfiguration(String conf) {
if (_md == null) {
throw new IllegalStateException("impossible to get configuration when data has not been loaded");
}
return _md.getConfiguration(conf);
}
public ResolvedModuleRevision getModuleRevision() {
return _module;
}
/**
*
* @param rootModuleConf
* @param mrid
* @param callerConf
* @param dependencyConfs '*' must have been resolved
* @param askedDependencyId the dependency revision id asked by the caller
*/
public void addCaller(String rootModuleConf, ModuleRevisionId mrid, String callerConf, String[] dependencyConfs, ModuleRevisionId askedDependencyId) {
Map callers = (Map)_callersByRootConf.get(rootModuleConf);
if (callers == null) {
callers = new HashMap();
_callersByRootConf.put(rootModuleConf, callers);
}
Caller caller = (Caller)callers.get(mrid);
if (caller == null) {
caller = new Caller(mrid, askedDependencyId);
callers.put(mrid, caller);
}
caller.addConfiguration(callerConf, dependencyConfs);
}
public Caller[] getCallers(String rootModuleConf) {
Map callers = (Map)_callersByRootConf.get(rootModuleConf);
if (callers == null) {
return new Caller[0];
}
return (Caller[])callers.values().toArray(new Caller[callers.values().size()]);
}
public String toString() {
return getResolvedId().toString();
}
public boolean equals(Object obj) {
if (! (obj instanceof IvyNode)) {
return false;
}
IvyNode node = (IvyNode)obj;
return node.getId().equals(getId());
}
public int hashCode() {
return getId().hashCode();
}
/**
* Returns the configurations of the dependency required in a given
* root module configuration.
* @param rootModuleConf
* @return
*/
public String[] getConfigurations(String rootModuleConf) {
Set depConfs = (Set) _rootModuleConfs.get(rootModuleConf);
if (depConfs == null) {
return new String[0];
}
return (String[]) depConfs.toArray(new String[depConfs.size()]);
}
private void addRootModuleConfigurations(String rootModuleConf, String[] dependencyConfs) {
Set depConfs = (Set) _rootModuleConfs.get(rootModuleConf);
if (depConfs == null) {
depConfs = new HashSet();
_rootModuleConfs.put(rootModuleConf, depConfs);
}
if (_md != null) {
// add all given dependency configurations to the set + extended ones
for (int i = 0; i < dependencyConfs.length; i++) {
Configuration conf = _md.getConfiguration(dependencyConfs[i]);
if (conf != null) {
String[] exts = conf.getExtends();
addRootModuleConfigurations(rootModuleConf, exts); // recursive add of extended configurations
depConfs.add(conf.getName());
} else {
Message.warn("unknown configuration in "+getId()+": "+dependencyConfs[i]);
}
}
} else {
for (int i = 0; i < dependencyConfs.length; i++) {
depConfs.add(dependencyConfs[i]);
}
}
}
/**
* Returns the root module configurations in which this dependency is required
* @return
*/
public String[] getRootModuleConfigurations() {
return (String[])_rootModuleConfs.keySet().toArray(new String[_rootModuleConfs.size()]);
}
/**
* Returns all the artifacts of this dependency required in all the
* root module configurations
* @return
*/
public Artifact[] getAllArtifacts() {
Set ret = new HashSet();
for (Iterator it = _rootModuleConfs.keySet().iterator(); it.hasNext();) {
String rootModuleConf = (String)it.next();
ret.addAll(Arrays.asList(getArtifacts(rootModuleConf)));
}
return (Artifact[])ret.toArray(new Artifact[ret.size()]);
}
/**
* Returns all the artifacts of this dependency required in the
* root module configurations in which the node is not evicted
* @return
*/
public Artifact[] getSelectedArtifacts() {
Set ret = new HashSet();
for (Iterator it = _rootModuleConfs.keySet().iterator(); it.hasNext();) {
String rootModuleConf = (String)it.next();
if (!isEvicted(rootModuleConf)) {
ret.addAll(Arrays.asList(getArtifacts(rootModuleConf)));
}
}
return (Artifact[])ret.toArray(new Artifact[ret.size()]);
}
/**
* Returns the artifacts of this dependency required in the
* configurations themselves required in the given root module configuration
* @param rootModuleConf
* @return
*/
public Artifact[] getArtifacts(String rootModuleConf) {
// first we look for the dependency configurations required
// in the given root module configuration
Set confs = (Set) _rootModuleConfs.get(rootModuleConf);
if (confs == null) {
// no configuration required => no artifact required
return new Artifact[0];
}
Set artifacts = new HashSet(); // the set we fill before returning
// we check if we have dependencyArtifacts includes description for this rootModuleConf
Set includes = (Set)_dependencyArtifactsIncludes.get(rootModuleConf);
if (_md.isDefault() && includes != null && !includes.isEmpty()) {
// the descriptor is a default one: it has been generated from nothing
// moreover, we have dependency artifacts description
// these descritions are thus used as if they were declared in the module
// descriptor. If one is not really present, the error will be raised
// at download time
for (Iterator it = includes.iterator(); it.hasNext();) {
DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)it.next();
artifacts.add(new MDArtifact(_md, dad.getName(), dad.getType(), dad.getExt()));
}
} else {
if (includes == null || includes.isEmpty()) {
// no artifacts includes: we get all artifacts as defined by the descriptor
for (Iterator iter = confs.iterator(); iter.hasNext();) {
String conf = (String) iter.next();
artifacts.addAll(Arrays.asList(_md.getArtifacts(conf)));
}
} else {
// we have to get only artifacts listed as "includes"
// first we get all artifacts as defined by the module descriptor
// and classify them by artifact id
Map allArtifacts = new HashMap();
for (Iterator iter = confs.iterator(); iter.hasNext();) {
String conf = (String) iter.next();
Artifact[] arts = _md.getArtifacts(conf);
for (int i = 0; i < arts.length; i++) {
allArtifacts.put(arts[i].getId().getArtifactId(), arts[i]);
}
}
// now we can keep only listed ones
for (Iterator it = includes.iterator(); it.hasNext();) {
DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)it.next();
Collection arts = findArtifactsMatching(dad.getId(), allArtifacts);
if (arts.isEmpty()) {
Message.error("a required artifact is not listed by module descriptor: "+dad.getId());
// we remove it from required list to prevent message to be displayed more than once
it.remove();
} else {
Message.debug(this+" in "+rootModuleConf+": including "+arts);
artifacts.addAll(arts);
}
}
}
}
// now excludes artifacts in the exclude list
Set excludes = (Set)_dependencyArtifactsExcludes.get(rootModuleConf);
if (excludes != null) {
for (Iterator it = excludes.iterator(); it.hasNext();) {
DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)it.next();
for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact)iter.next();
if (artifactIdMatch(dad.getId(), artifact.getId().getArtifactId())) {
Message.debug(this+" in "+rootModuleConf+": excluding "+artifact);
iter.remove();
}
}
}
}
return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
}
private Collection findArtifactsMatching(ArtifactId id, Map allArtifacts) {
Artifact art = (Artifact)allArtifacts.get(id);
if (art != null) {
return Collections.singleton(art);
}
Collection ret = new ArrayList();
for (Iterator iter = allArtifacts.keySet().iterator(); iter.hasNext();) {
ArtifactId aid = (ArtifactId)iter.next();
if (artifactIdMatch(id, aid)) {
ret.add(allArtifacts.get(aid));
}
}
return ret;
}
private boolean artifactIdMatch(ArtifactId id, ArtifactId aid) {
if (aid.equals(id)) {
return true;
}
return stringMatch(id.getModuleId().getOrganisation(), aid.getModuleId().getOrganisation())
&& stringMatch(id.getModuleId().getName(), aid.getModuleId().getName())
&& stringMatch(id.getName(), aid.getName())
&& stringMatch(id.getExt(), aid.getExt())
&& stringMatch(id.getType(), aid.getType())
;
}
private boolean stringMatch(String pattern, String test) {
if (test.equals(pattern)) {
return true;
}
return Pattern.matches(pattern, test);
}
private void addDependencyArtifactsIncludes(String rootModuleConf, DependencyArtifactDescriptor[] dependencyArtifacts) {
addDependencyArtifacts(rootModuleConf, dependencyArtifacts, _dependencyArtifactsIncludes);
}
private void addDependencyArtifactsExcludes(String rootModuleConf, DependencyArtifactDescriptor[] dependencyArtifacts) {
addDependencyArtifacts(rootModuleConf, dependencyArtifacts, _dependencyArtifactsExcludes);
}
private void addDependencyArtifacts(String rootModuleConf, DependencyArtifactDescriptor[] dependencyArtifacts, Map artifactsMap) {
Set depArtifacts = (Set) artifactsMap.get(rootModuleConf);
if (depArtifacts == null) {
depArtifacts = new HashSet();
artifactsMap.put(rootModuleConf, depArtifacts);
}
depArtifacts.addAll(Arrays.asList(dependencyArtifacts));
}
public long getPublication() {
if (_module != null) {
return _module.getPublicationDate().getTime();
}
return 0;
}
public DependencyDescriptor getDependencyDescriptor() {
return _dd;
}
public boolean hasProblem() {
return _problem != null;
}
public ModuleRevisionId getResolvedId() {
if (_md != null && _md.getResolvedModuleRevisionId().getRevision() != null) {
return _md.getResolvedModuleRevisionId();
} else if (_module != null) {
return _module.getId();
} else {
return getId();
}
}
public Exception getProblem() {
return _problem;
}
public boolean isDownloaded() {
return _downloaded;
}
public boolean isSearched() {
return _searched;
}
public String getRootModuleConf() {
return _rootModuleConf;
}
public void setRootModuleConf(String rootModuleConf) {
if (rootModuleConf != null && rootModuleConf.equals(_rootModuleConf)) {
_selected.put(new ModuleIdConf(_id.getModuleId(), rootModuleConf), Collections.singleton(this));
}
_rootModuleConf = rootModuleConf;
}
public String[] getConfsToFetch() {
return (String[])_confsToFetch.toArray(new String[_confsToFetch.size()]);
}
/**
* Returns true if this node can already be found among its callers
* @return
*/
public boolean isCircular() {
return isCircular(this);
}
private boolean isCircular(IvyNode node) {
boolean isCircular = false;
IvyNode.Caller[] callers = node.getCallers(getRootModuleConf());
for (int i = 0; i < callers.length && !isCircular; i++) {
ModuleRevisionId mrid = callers[i].getModuleRevisionId();
if (getId().equals(mrid)) {
return true;
}
IvyNode parent = _data.getNode(mrid);
if (parent != null) {
isCircular = isCircular(parent);
}
}
return isCircular;
}
}

View File

@ -0,0 +1,24 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.Date;
public interface LatestStrategy {
/**
* Finds the latest artifact among the given artifacts info.
* The definition of 'latest' depends on the strategy itself.
* Given artifacts info are all good candidate. If the given date is not
* null, then found artifact should not be later than this date.
*
* @param infos
* @param date
* @return the latest artifact among the given ones.
*/
ArtifactInfo findLatest(ArtifactInfo[] infos, Date date);
String getName();
}

View File

@ -0,0 +1,24 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
public class License {
private String _name;
private String _url;
public License(String name, String url) {
_name = name;
_url = url;
}
public String getName() {
return _name;
}
public String getUrl() {
return _url;
}
}

View File

@ -0,0 +1,77 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author x.hanin
*
*/
public class MDArtifact extends AbstractArtifact {
private ModuleDescriptor _md;
private String _name;
private String _type;
private String _ext;
private List _confs = new ArrayList();
private ArtifactRevisionId _arid;
public MDArtifact(ModuleDescriptor md, String name, String type, String ext) {
if (md == null) {
throw new NullPointerException("null module descriptor not allowed");
}
if (name == null) {
throw new NullPointerException("null name not allowed");
}
if (type == null) {
throw new NullPointerException("null type not allowed");
}
if (ext == null) {
throw new NullPointerException("null ext not allowed");
}
_md = md;
_name = name;
_type = type;
_ext = ext;
}
public ModuleRevisionId getModuleRevisionId() {
return _md.getResolvedModuleRevisionId();
}
public Date getPublicationDate() {
return _md.getResolvedPublicationDate();
}
public ArtifactRevisionId getId() {
if (_arid == null) {
_arid = ArtifactRevisionId.newInstance(_md.getResolvedModuleRevisionId(), _name, _type, _ext);
}
return _arid;
}
public String getName() {
return _name;
}
public String getType() {
return _type;
}
public String getExt() {
return _ext;
}
public String[] getConfigurations() {
return (String[])_confs.toArray(new String[_confs.size()]);
}
public void addConfiguration(String conf) {
_confs.add(conf);
}
}

View File

@ -0,0 +1,203 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.io.File;
import java.util.Date;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import fr.jayasoft.ivy.util.DefaultMessageImpl;
import fr.jayasoft.ivy.util.Message;
/**
* class used to launch ivy as a standalone tool
* arguments are :
* -conf <conffile> : indicates the path to the ivy configuration file
* ivyconf.xml is assumed if not given
* -cache <cachedir> : indicates the path to the cache directory
* cache is assumed if not given
* -ivy <ivyfile> : indicates the path to the ivy file to use
* ivy.xml is assumed if not given
* -retrieve <retrievepattern> : when used, retrieve is also done using the given retrievepattern
* -revision <revision> : the revision with which the module should be published, required to publish
* -status <status> : the status with which the module should be published,
* release is assumed if not given
* -publish <publishpattern> : the pattern used to publish the resolved ivy file,
* ivy-[revision].xml is assumed if not given
*/
public class Main {
private static Options getOptions() {
Option conf = OptionBuilder.withArgName( "conffile" )
.hasArg()
.withDescription( "use given file for configuration" )
.create( "conf" );
Option cache = OptionBuilder.withArgName( "cachedir" )
.hasArg()
.withDescription( "use given directory for cache" )
.create( "cache" );
Option ivyfile = OptionBuilder.withArgName( "ivyfile" )
.hasArg()
.withDescription( "use given file as ivy file" )
.create( "ivy" );
Option confs = OptionBuilder.withArgName( "configurations" )
.hasArgs()
.withDescription( "resolve given configurations" )
.create( "confs" );
Option retrieve = OptionBuilder.withArgName( "retrievepattern" )
.hasArg()
.withDescription( "use given pattern as retrieve pattern" )
.create( "retrieve" );
Option revision = OptionBuilder.withArgName( "revision" )
.hasArg()
.withDescription( "use given revision to publish the module" )
.create( "revision" );
Option status = OptionBuilder.withArgName( "status" )
.hasArg()
.withDescription( "use given status to publish the module" )
.create( "status" );
Option publish = OptionBuilder.withArgName( "publishpattern" )
.hasArg()
.withDescription( "use given pattern as resolved ivy file pattern" )
.create( "publish" );
Options options = new Options();
options.addOption("debug", false, "set message level to debug");
options.addOption("verbose", false, "set message level to verbose");
options.addOption("warn", false, "set message level to warn");
options.addOption("error", false, "set message level to error");
options.addOption("novalidate", false, "do not validate ivy files against xsd");
options.addOption("?", false, "display this help");
options.addOption(conf);
options.addOption(confs);
options.addOption(cache);
options.addOption(ivyfile);
options.addOption(retrieve);
options.addOption(revision);
options.addOption(status);
options.addOption(publish);
return options;
}
public static void main(String[] args) throws Exception {
Options options = getOptions();
CommandLineParser parser = new GnuParser();
try {
// parse the command line arguments
CommandLine line = parser.parse( options, args );
if (line.hasOption("?")) {
usage(options);
return;
}
if (line.hasOption("debug")) {
Message.init(new DefaultMessageImpl(Message.MSG_DEBUG));
} else if (line.hasOption("verbose")) {
Message.init(new DefaultMessageImpl(Message.MSG_VERBOSE));
} else if (line.hasOption("warn")) {
Message.init(new DefaultMessageImpl(Message.MSG_WARN));
} else if (line.hasOption("error")) {
Message.init(new DefaultMessageImpl(Message.MSG_ERR));
} else {
Message.init(new DefaultMessageImpl(Message.MSG_INFO));
}
boolean validate = line.hasOption("novalidate")?false:true;
Ivy ivy = new Ivy();
String confPath = line.getOptionValue("conf", "");
if ("".equals(confPath)) {
ivy.configure(Ivy.class.getResource("ivyconf.xml"));
} else {
File conffile = new File(confPath);
if (!conffile.exists()) {
error(options, "ivy configuration file not found: "+conffile);
} else if (conffile.isDirectory()) {
error(options, "ivy configuration file is not a file: "+conffile);
}
ivy.configure(conffile);
}
File cache = new File(ivy.substitute(line.getOptionValue("cache", "cache")));
if (!cache.exists()) {
cache.mkdirs();
} else if (!cache.isDirectory()) {
error(options, cache+" is not a directory");
}
File ivyfile = new File(ivy.substitute(line.getOptionValue("ivy", "ivy.xml")));
if (!ivyfile.exists()) {
error(options, "ivy file not found: "+ivyfile);
} else if (ivyfile.isDirectory()) {
error(options, "ivy file is not a file: "+ivyfile);
}
String[] confs;
if (line.hasOption("confs")) {
confs = line.getOptionValues("confs");
} else {
confs = new String[] {"*"};
}
Date date = new Date();
ModuleDescriptor md = ivy.resolve(
ivyfile.toURL(),
null,
confs,
cache,
date,
validate).getModuleDescriptor();
if (line.hasOption("retrieve")) {
String retrievePattern = ivy.substitute(line.getOptionValue("retrieve"));
if (retrievePattern.indexOf("[") == -1) {
retrievePattern = retrievePattern + "/lib/[conf]/[artifact].[type]";
}
ivy.retrieve(md.getModuleRevisionId().getModuleId(), confs, cache, retrievePattern);
}
if (line.hasOption("revision")) {
ivy.deliver(
md.getResolvedModuleRevisionId(),
ivy.substitute(line.getOptionValue("revision")),
cache,
ivy.substitute(line.getOptionValue("publish", "ivy-[revision].xml")),
ivy.substitute(line.getOptionValue("status", "release")),
date,
new DefaultPublishingDRResolver(),
validate);
}
} catch( ParseException exp ) {
// oops, something went wrong
System.err.println( "Parsing failed. Reason: " + exp.getMessage() );
usage(options);
}
}
private static void error(Options options, String msg) {
System.err.println(msg);
usage(options);
System.exit(1);
}
private static void usage(Options options) {
// automatically generate the help statement
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( "ivy", options );
}
}

View File

@ -0,0 +1,99 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.Date;
/**
* @author x.hanin
*
*/
public interface ModuleDescriptor {
public static final String DEFAULT_CONFIGURATION = "default";
/**
* Returns true if this descriptor is a default one, i.e.
* one generated for a module not actually having one.
* @return
*/
boolean isDefault();
ModuleRevisionId getModuleRevisionId();
/**
* The module revision id returned here is the resolved one,
* i.e. it is never a latest one. If the revision has not been
* resolved, a null revision should be returned by getRevision()
* of the returned ModuleRevisionId.
* This revision must be the same as the module descriptor resolved
* revision id unless no module descriptor is defined
* @return
*/
ModuleRevisionId getResolvedModuleRevisionId();
/**
* This method update the resolved module revision id
* @param revId
*/
void setResolvedModuleRevisionId(ModuleRevisionId revId);
/**
* This method update the resolved publication date
* @param publicationDate
*/
void setResolvedPublicationDate(Date publicationDate);
String getResolverName();
void setResolverName(String resolverName);
String getStatus();
/**
* may be null if unknown in the descriptor itself
* @return
*/
Date getPublicationDate();
/**
* the publication date of the module revision should be the date at which it has been published,
* i.e. in general the date of any of its published artifacts, since all published artifact
* of a module should follow the same publishing cycle.
*/
Date getResolvedPublicationDate();
/**
* Returns all the configurations declared by this module as an array.
* This array is never empty (a 'default' conf is assumed when none is declared
* in the ivy file)
* @return all the configurations declared by this module as an array.
*/
Configuration[] getConfigurations();
String[] getConfigurationsNames();
Artifact[] getArtifacts(String conf);
DependencyDescriptor[] getDependencies();
/**
* Returns true if the module described by this descriptor dependes directly upon the
* given module descriptor
* @param md
* @return
*/
boolean dependsOn(ModuleDescriptor md);
/**
* @param confName
* @return
*/
Configuration getConfiguration(String confName);
/**
* Returns the conflict manager to use for the given ModuleId
*
* @param id
* @return
*/
ConflictManager getConflictManager(ModuleId id);
/**
* Returns the licenses of the module described by this descriptor
* @return
*/
License[] getLicenses();
String getHomePage();
long getLastModified();
}

View File

@ -0,0 +1,48 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* @author x.hanin
*
*/
public class ModuleId {
private String _organisation;
private String _name;
public ModuleId(String organisation, String name) {
if (name == null) {
throw new IllegalArgumentException("null name not allowed");
}
_organisation = organisation;
_name = name;
}
public String getName() {
return _name;
}
public String getOrganisation() {
return _organisation;
}
public boolean equals(Object obj) {
if (! (obj instanceof ModuleId)) {
return false;
}
ModuleId other = (ModuleId)obj;
return other._organisation.equals(_organisation) && other._name.equals(_name);
}
public int hashCode() {
int hash = 31;
hash = hash * 13 + _organisation.hashCode();
hash = hash * 13 + _name.hashCode();
return hash;
}
public String toString() {
return _organisation+"/"+_name;
}
}

View File

@ -0,0 +1,81 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* @author x.hanin
*
*/
public class ModuleRevisionId {
public static ModuleRevisionId newInstance(String organisation, String name, String revision) {
return new ModuleRevisionId(new ModuleId(organisation, name), revision);
}
private ModuleId _moduleId;
private String _revision;
public ModuleRevisionId(ModuleId moduleId, String revision) {
_moduleId = moduleId;
_revision = revision;
}
public ModuleId getModuleId() {
return _moduleId;
}
public String getName() {
return getModuleId().getName();
}
public String getOrganisation() {
return getModuleId().getOrganisation();
}
public String getRevision() {
return _revision;
}
public boolean equals(Object obj) {
if (! (obj instanceof ModuleRevisionId)) {
return false;
}
ModuleRevisionId other = (ModuleRevisionId)obj;
return (other.getRevision() == null ? getRevision() == null : other.getRevision().equals(getRevision()))
&& other.getModuleId().equals(getModuleId());
}
public int hashCode() {
int hash = 31;
hash = hash * 13 + (getRevision() == null ? 0 : getRevision().hashCode());
hash = hash * 13 + getModuleId().hashCode();
return hash;
}
public String toString() {
return _moduleId+"-"+_revision;
}
/**
* Returns true if the given revision can be considered as a revision of this module revision id.
* This is the case if the revision is equal to the current revision, or if the
* current revision is a 'latest.' one, or if it is a xx+ one matching the given one.
* @param revision
* @return true if the given revision can be considered as a revision of this module revision id.
*/
public boolean acceptRevision(String revision) {
if (_revision.equals(revision)) {
return true;
}
if (_revision.startsWith("latest.")) {
return true;
}
if (_revision.endsWith("+") && revision.startsWith(_revision.substring(0, _revision.length() - 1))) {
return true;
}
return false;
}
/**
* @return true if the revision is an exact one, i.e. not a 'latest.' nor a xx+ one.
*/
public boolean isExactRevision() {
return !_revision.startsWith("latest.") && !_revision.endsWith("+");
}
}

View File

@ -0,0 +1,24 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
/**
* @author Xavier Hanin
*
*/
public interface PublishingDependencyRevisionResolver {
/**
* Returns the revision of the dependency for the publishing of the 'published' module
* in 'publishedStatus' status.
* @param published
* @param publishedStatus
* @param dependency
* @return the revision of the dependency
*/
String resolve(ModuleDescriptor published, String publishedStatus, ModuleDescriptor dependency);
}

View File

@ -0,0 +1,83 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import fr.jayasoft.ivy.report.ConfigurationResolveReport;
public class ResolveData {
private Map _nodes; // shared map of all nodes: Map (ModuleRevisionId -> IvyNode)
private Ivy _ivy;
private File _cache;
private Date _date;
private boolean _validate;
private ConfigurationResolveReport _report;
public ResolveData(ResolveData data, boolean validate) {
this(data._ivy, data._cache, data._date, data._report, validate, data._nodes);
}
public ResolveData(Ivy ivy, File cache, Date date, ConfigurationResolveReport report, boolean validate) {
this(ivy, cache, date, report, validate, new HashMap());
}
public ResolveData(Ivy ivy, File cache, Date date, ConfigurationResolveReport report, boolean validate, Map nodes) {
_ivy = ivy;
_cache = cache;
_date = date;
_report = report;
_validate = validate;
_nodes = nodes;
}
public File getCache() {
return _cache;
}
public Date getDate() {
return _date;
}
public Ivy getIvy() {
return _ivy;
}
public Map getNodes() {
return _nodes;
}
public ConfigurationResolveReport getReport() {
return _report;
}
public boolean isValidate() {
return _validate;
}
public IvyNode getNode(ModuleRevisionId mrid) {
return (IvyNode)_nodes.get(mrid);
}
public void register(IvyNode node) {
_nodes.put(node.getId(), node);
}
public void register(ModuleRevisionId id, IvyNode node) {
_nodes.put(id, node);
}
}

View File

@ -0,0 +1,21 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.Date;
/**
* @author x.hanin
*
*/
public interface ResolvedModuleRevision {
DependencyResolver getResolver();
ModuleRevisionId getId();
Date getPublicationDate();
ModuleDescriptor getDescriptor();
boolean isDownloaded();
boolean isSearched();
}

View File

@ -0,0 +1,48 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import fr.jayasoft.ivy.util.Message;
public class ResolvedURL implements ArtifactInfo {
URL url;
String revision;
private Long _lastModified;
public ResolvedURL(URL url, String revision) {
this.url = url;
this.revision = revision;
}
public String toString() {
return url + "(" + revision + ")";
}
public String getRevision() {
return revision;
}
public long getLastModified() {
if (_lastModified == null) {
try {
URLConnection con = url.openConnection();
_lastModified = new Long(con.getLastModified());
} catch (IOException e) {
Message.warn("impossible to open connection to "+url+": "+e.getMessage());
_lastModified = new Long(0);
}
}
return _lastModified.longValue();
}
public URL getURL() {
return url;
}
}

View File

@ -0,0 +1,52 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy;
import java.util.HashMap;
import java.util.Map;
/**
* @author x.hanin
*
*/
public class Status {
public static final String DEFAULT_STATUS = "integration";
private static final String[] STATUSES = new String[] {"release", "milestone", "integration"};
private static final boolean[] IS_INTEGRATION = new boolean[] {false, false, true};
private static Map _statusPriorityMap;
private static Map _statusIntegrationMap;
static {
_statusPriorityMap = new HashMap();
for (int i = 0; i < STATUSES.length; i++) {
_statusPriorityMap.put(STATUSES[i], new Integer(i));
}
_statusIntegrationMap = new HashMap();
for (int i = 0; i < IS_INTEGRATION.length; i++) {
_statusIntegrationMap.put(STATUSES[i], new Boolean(IS_INTEGRATION[i]));
}
}
public static int getPriority(String status) {
Integer priority = (Integer)_statusPriorityMap.get(status);
if (priority == null) {
throw new IllegalArgumentException("unknown status "+status);
}
return priority.intValue();
}
public static boolean isIntegration(String status) {
Boolean isIntegration = (Boolean)_statusIntegrationMap.get(status);
if (isIntegration == null) {
throw new IllegalArgumentException("unknown status "+status);
}
return isIntegration.booleanValue();
}
public static String getDeliveryStatusListString() {
// TODO : use constants
return "milestone,release";
}
}

View File

@ -0,0 +1,50 @@
/*
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
* Copyright Jayasoft 2005 - All rights reserved
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import org.apache.tools.ant.Project;
import fr.jayasoft.ivy.util.MessageImpl;
public class AntMessageImpl implements MessageImpl {
private Project _project;
private static long _lastProgressFlush = 0;
private static StringBuffer _buf = new StringBuffer();
/**
* @param project
*/
public AntMessageImpl(Project project) {
_project = project;
}
public void log(String msg, int level) {
_project.log(msg, level);
}
public void progress() {
_buf.append(".");
if (_lastProgressFlush == 0) {
_lastProgressFlush = System.currentTimeMillis();
}
if (_project != null) {
// log with ant causes a new line -> we do it only once in a while
if (System.currentTimeMillis() - _lastProgressFlush > 1500) {
_project.log(_buf.toString());
_buf.setLength(0);
_lastProgressFlush = System.currentTimeMillis();
}
}
}
public void endProgress(String msg) {
_project.log(_buf + msg);
_buf.setLength(0);
_lastProgressFlush = 0;
}
}

View File

@ -0,0 +1,110 @@
/*
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
* Copyright Jayasoft 2005 - All rights reserved
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import org.apache.tools.ant.BuildException;
import fr.jayasoft.ivy.Artifact;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleId;
import fr.jayasoft.ivy.util.IvyPatternHelper;
import fr.jayasoft.ivy.xml.XmlReportParser;
public class IvyArtifactProperty extends IvyTask {
private String _conf;
private String _name;
private String _value;
private String _organisation;
private String _module;
private boolean _haltOnFailure = true;
private File _cache;
public String getConf() {
return _conf;
}
public void setConf(String conf) {
_conf = conf;
}
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
public String getValue() {
return _value;
}
public void setValue(String value) {
_value = value;
}
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public boolean isHaltonfailure() {
return _haltOnFailure;
}
public void setHaltonfailure(boolean haltOnFailure) {
_haltOnFailure = haltOnFailure;
}
public File getCache() {
return _cache;
}
public void setCache(File cache) {
_cache = cache;
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
ensureResolved(isHaltonfailure());
_conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
if (_conf.equals("*")) {
_conf = getProperty(ivy, "ivy.resolved.configurations");
}
_organisation = getProperty(_organisation, ivy, "ivy.organisation");
_module = getProperty(_module, ivy, "ivy.module");
if (_cache == null) {
_cache = ivy.getDefaultCache();
}
if (_organisation == null || _module == null) {
throw new BuildException("no module id provided for ivy artifact property: either call resolve, give paramaters to ivy:retrieve, or provide ivy.module and ivy.organisation properties");
}
try {
XmlReportParser parser = new XmlReportParser();
String[] confs = splitConfs(_conf);
Collection all = new HashSet();
for (int i = 0; i < confs.length; i++) {
Artifact[] artifacts = parser.getArtifacts(new ModuleId(_organisation, _module), confs[i], _cache);
all.addAll(Arrays.asList(artifacts));
}
for (Iterator iter = all.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact)iter.next();
String name = IvyPatternHelper.substitute(ivy.substitute(getName()), artifact);
String value = IvyPatternHelper.substitute(ivy.substitute(getValue()), artifact);
getProject().setProperty(name, value);
}
} catch (Exception ex) {
throw new BuildException("impossible to add artifact properties: "+ex.getMessage(), ex);
}
}
}

View File

@ -0,0 +1,116 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.Path;
import fr.jayasoft.ivy.Artifact;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleId;
import fr.jayasoft.ivy.xml.XmlReportParser;
public class IvyCachePath extends IvyTask {
private String _conf;
private String _pathid;
private String _organisation;
private String _module;
private boolean _haltOnFailure = true;
private File _cache;
public String getConf() {
return _conf;
}
public void setConf(String conf) {
_conf = conf;
}
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public boolean isHaltonfailure() {
return _haltOnFailure;
}
public void setHaltonfailure(boolean haltOnFailure) {
_haltOnFailure = haltOnFailure;
}
public File getCache() {
return _cache;
}
public void setCache(File cache) {
_cache = cache;
}
public String getPathid() {
return _pathid;
}
public void setPathid(String id) {
_pathid = id;
}
/**
* @deprecated use setPathid instead
* @param id
*/
public void setId(String id) {
_pathid = id;
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
if (_pathid == null) {
throw new BuildException("pathid is required in ivy classpath");
}
ensureResolved(isHaltonfailure());
_conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
if (_conf.equals("*")) {
_conf = getProperty(ivy, "ivy.resolved.configurations");
}
_organisation = getProperty(_organisation, ivy, "ivy.organisation");
_module = getProperty(_module, ivy, "ivy.module");
if (_cache == null) {
_cache = ivy.getDefaultCache();
}
if (_organisation == null || _module == null) {
throw new BuildException("no module id provided for ivy path: either call resolve, give paramaters to ivy:retrieve, or provide ivy.module and ivy.organisation properties");
}
try {
XmlReportParser parser = new XmlReportParser();
Path path = new Path(getProject());
getProject().addReference(_pathid, path);
String[] confs = splitConfs(_conf);
Collection all = new HashSet();
for (int i = 0; i < confs.length; i++) {
Artifact[] artifacts = parser.getArtifacts(new ModuleId(_organisation, _module), confs[i], _cache);
all.addAll(Arrays.asList(artifacts));
}
for (Iterator iter = all.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact)iter.next();
path.createPathElement().setLocation(ivy.getArchiveFileInCache(_cache, artifact));
}
} catch (Exception ex) {
throw new BuildException("impossible to build ivy path: "+ex.getMessage(), ex);
}
}
}

View File

@ -0,0 +1,74 @@
/*
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
* Copyright Jayasoft 2005 - All rights reserved
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.util.Message;
public class IvyCheck extends IvyTask {
private File _file = null;
private List _filesets = new ArrayList();
private String _resolvername;
public File getFile() {
return _file;
}
public void setFile(File file) {
_file = file;
}
/**
* Adds a set of files to check.
* @param set a set of files to check
*/
public void addFileset(FileSet set) {
_filesets.add(set);
}
public String getResolvername() {
return _resolvername;
}
public void setResolvername(String resolverName) {
_resolvername = resolverName;
}
public void execute() throws BuildException {
try {
Ivy ivy = getIvyInstance();
if (_file != null) {
if (ivy.check(_file.toURL(), _resolvername)) {
Message.verbose("checked "+_file+": OK");
}
}
for (int i = 0; i < _filesets.size(); i++) {
FileSet fs = (FileSet) _filesets.get(i);
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File fromDir = fs.getDir(getProject());
String[] srcFiles = ds.getIncludedFiles();
for (int j = 0; j < srcFiles.length; j++) {
File file = new File(fromDir, srcFiles[j]);
if (ivy.check(file.toURL(), _resolvername)) {
Message.verbose("checked "+file+": OK");
}
}
}
} catch (MalformedURLException e) {
throw new BuildException("impossible to convert a file to an url!", e);
}
}
}

View File

@ -0,0 +1,144 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Property;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.url.URLHandlerDispatcher;
import fr.jayasoft.ivy.url.URLHandlerRegistry;
import fr.jayasoft.ivy.util.Message;
/**
* @author Hanin
*
*/
public class IvyConfigure extends IvyTask {
private File _file = null;
private URL _url = null;
private String _realm = null;
private String _host = null;
private String _userName = null;
private String _passwd = null;
public File getFile() {
return _file;
}
public void setFile(File conf) {
_file = conf;
}
public URL getUrl() {
return _url;
}
public void setUrl(String url) throws MalformedURLException {
_url = new URL(url);
}
public String getPasswd() {
return _passwd;
}
public void setPasswd(String passwd) {
_passwd = passwd;
}
public String getRealm() {
return _realm;
}
public void setRealm(String realm) {
_realm = format(realm);
}
public String getHost() {
return _host;
}
public void setHost(String host) {
_host = format(host);
}
public String getUsername() {
return _userName;
}
public void setUsername(String userName) {
_userName = format(userName);
}
private String format(String str) {
return str == null ? str : (str.trim().length() == 0 ? null : str.trim());
}
public void execute() throws BuildException {
try {
loadDefaultProperties();
} catch (Exception ex) {
throw new BuildException("impossible to load ivy default properties file: "+ex.getMessage(), ex);
}
Message.init(new AntMessageImpl(getProject()));
Ivy ivy = new Ivy();
try {
configureURLHandler();
ivy.addAllVariables(getProject().getProperties());
if (_file == null && _url == null) {
_file = new File(getProject().getBaseDir(), getProject().getProperty("ivy.conf.file"));
Message.verbose("searching ivyconf file: trying "+_file);
if (!_file.exists()) {
_file = new File(getProject().getProperty("ivy.conf.file"));
Message.verbose("searching ivyconf file: trying "+_file);
if (!_file.exists()) {
Message.info("no configuration file found, using default...");
_file = null;
_url = Ivy.class.getResource("ivyconf.xml");
}
}
}
if (_file != null) {
if (!_file.exists()) {
throw new BuildException("configuration file does not exist: "+_file);
} else {
ivy.configure(_file);
}
} else {
ivy.configure(_url);
}
setIvyInstance(ivy);
} catch (Exception ex) {
throw new BuildException("impossible to configure ivy with given file: "+ex.getMessage(), ex);
}
}
private void loadDefaultProperties() {
Property prop = new Property() {
public void execute() throws BuildException {
URL url = IvyConfigure.class.getResource("ivy.properties");
// this is copy of loadURL code from ant Property task (not available in 1.5.1)
Properties props = new Properties();
log("Loading " + url, Project.MSG_VERBOSE);
try {
InputStream is = url.openStream();
try {
props.load(is);
} finally {
if (is != null) {
is.close();
}
}
addProperties(props);
} catch (IOException ex) {
throw new BuildException(ex, getLocation());
}
}
};
prop.setProject(getProject());
prop.execute();
}
private void configureURLHandler() {
URLHandlerDispatcher dispatcher = new URLHandlerDispatcher();
dispatcher.setDownloader("http", URLHandlerRegistry.getHttp(getRealm(), getHost(), getUsername(), getPasswd()));
URLHandlerRegistry.setDefault(dispatcher);
}
}

View File

@ -0,0 +1,265 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.util.Date;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.CallTarget;
import org.apache.tools.ant.taskdefs.Echo;
import org.apache.tools.ant.taskdefs.Input;
import org.apache.tools.ant.taskdefs.Property;
import fr.jayasoft.ivy.DefaultPublishingDRResolver;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleDescriptor;
import fr.jayasoft.ivy.ModuleRevisionId;
import fr.jayasoft.ivy.PublishingDependencyRevisionResolver;
import fr.jayasoft.ivy.Status;
/**
* @author Hanin
*
*/
public class IvyDeliver extends IvyTask {
private final class DeliverDRResolver implements PublishingDependencyRevisionResolver {
public String resolve(ModuleDescriptor published, String publishedStatus, ModuleDescriptor dependency) {
if (Status.isIntegration(publishedStatus)) {
// published status is integration one, nothing to ask
return dependency.getResolvedModuleRevisionId().getRevision();
}
// we are publishing a delivery (a non integration module)
if (!Status.isIntegration(dependency.getStatus())) {
// dependency is already a delivery, nothing to ask
return dependency.getResolvedModuleRevisionId().getRevision();
}
// the dependency is not a delivery
// we must ask the user what version and status he want to have
// for the dependency
String statusProperty = dependency.getModuleRevisionId().getName()+"."+dependency.getModuleRevisionId().getRevision()+".status";
String versionProperty = dependency.getModuleRevisionId().getName()+"."+dependency.getModuleRevisionId().getRevision()+".version";
String version = getProject().getProperty(versionProperty);
String status = getProject().getProperty(statusProperty);
log("found version = "+version+" status="+status);
if (version != null && status != null) {
// delivery has already been done : just return the value
return version;
}
Input input = (Input)getProject().createTask("input");
input.setOwningTarget(getOwningTarget());
input.init();
// ask status
input.setMessage(dependency.getModuleRevisionId().getName()+" "+dependency.getModuleRevisionId().getRevision()+": please enter a status: ");
input.setValidargs(Status.getDeliveryStatusListString());
input.setAddproperty(statusProperty);
input.perform();
appendDeliveryList(statusProperty + " = "+getProject().getProperty(statusProperty));
// ask version
input.setMessage(dependency.getModuleRevisionId().getName()+" "+dependency.getModuleRevisionId().getRevision()+": please enter a version: ");
input.setValidargs(null);
input.setAddproperty(versionProperty);
input.perform();
appendDeliveryList(versionProperty + " = "+getProject().getProperty(versionProperty));
version = getProject().getProperty(versionProperty);
deliverDependency(dependency, version);
loadDeliveryList();
return version;
}
public void deliverDependency(ModuleDescriptor dependency, String version) {
// call deliver target if any
if (_deliverTarget != null) {
String statusProperty = dependency.getModuleRevisionId().getName()+"."+dependency.getModuleRevisionId().getRevision()+".status";
String status = getProject().getProperty(statusProperty);
CallTarget ct = (CallTarget)getProject().createTask("antcall");
ct.setOwningTarget(getOwningTarget());
ct.init();
ct.setTarget(_deliverTarget);
ct.setInheritAll(true);
ct.setInheritRefs(true);
Property param = ct.createParam();
param.setName("dependency.name");
param.setValue(dependency.getModuleRevisionId().getName());
param = ct.createParam();
param.setName("dependency.published.status");
param.setValue(status);
param = ct.createParam();
param.setName("dependency.published.version");
param.setValue(version);
param = ct.createParam();
param.setName("dependency.version");
param.setValue(dependency.getModuleRevisionId().getRevision());
ct.perform();
}
}
}
private String _organisation;
private String _module;
private String _revision;
private String _pubRevision;
private File _cache;
private String _deliverpattern;
private String _status;
private String _pubdate;
private String _deliverTarget;
private File _deliveryList;
public File getCache() {
return _cache;
}
public void setCache(File cache) {
_cache = cache;
}
public String getDeliverpattern() {
return _deliverpattern;
}
public void setDeliverpattern(String destivypattern) {
_deliverpattern = destivypattern;
}
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public String getPubdate() {
return _pubdate;
}
public void setPubdate(String pubdate) {
_pubdate = pubdate;
}
public String getPubrevision() {
return _pubRevision;
}
public void setPubrevision(String pubRevision) {
_pubRevision = pubRevision;
}
public String getRevision() {
return _revision;
}
public void setRevision(String revision) {
_revision = revision;
}
public String getStatus() {
return _status;
}
public void setStatus(String status) {
_status = status;
}
public void setDelivertarget(String deliverTarget) {
_deliverTarget = deliverTarget;
}
public void setDeliveryList(File deliveryList) {
_deliveryList = deliveryList;
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
_organisation = getProperty(_organisation, ivy, "ivy.organisation");
_module = getProperty(_module, ivy, "ivy.module");
_revision = getProperty(_revision, ivy, "ivy.revision");
_pubRevision = getProperty(_pubRevision, ivy, "ivy.deliver.revision");
if (_cache == null) {
_cache = ivy.getDefaultCache();
}
_deliverpattern = getProperty(_deliverpattern, ivy, "ivy.deliver.ivy.pattern");
_status = getProperty(_status, ivy, "ivy.status");
if (_deliveryList == null) {
String deliveryListPath = getProperty(ivy, "ivy.delivery.list.file");
if (deliveryListPath == null) {
_deliveryList = new File(System.getProperty("java.io.tmpdir")+"/delivery.properties");
} else {
_deliveryList = getProject().resolveFile(ivy.substitute(deliveryListPath));
}
}
if (_module == null || _organisation == null || _revision == null) {
throw new BuildException("empty or incomplete module revision id provided for deliver: either call resolve, give paramaters to deliver, or provide ivy.module, ivy.organisation and ivy.revision properties");
}
Date pubdate = getPubDate(_pubdate, new Date());
if (_pubRevision == null) {
if (_revision.startsWith("working@")) {
_pubRevision = Ivy.DATE_FORMAT.format(pubdate);
} else {
_pubRevision = _revision;
}
}
if (_deliverpattern == null) {
throw new BuildException("deliver ivy pattern is missing: either provide it as parameters or through ivy.deliver.ivy.pattern properties");
}
if (_status == null) {
throw new BuildException("no status provided: either provide it as parameter or through the ivy.status.default property");
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
boolean isLeading = false;
try {
if (!_deliveryList.exists()) {
isLeading = true;
}
loadDeliveryList();
PublishingDependencyRevisionResolver drResolver;
if (_deliverTarget!=null) {
drResolver = new DeliverDRResolver();
} else {
drResolver = new DefaultPublishingDRResolver();
}
ivy.deliver(mrid, _pubRevision, _cache, _deliverpattern, _status, pubdate,
drResolver, doValidate(ivy));
} catch (Exception e) {
throw new BuildException("impossible to deliver "+mrid+": "+e.getMessage(), e);
} finally {
if (isLeading) {
if (_deliveryList.exists()) {
_deliveryList.delete();
}
}
}
}
private void loadDeliveryList() {
Property property = (Property)getProject().createTask("property");
property.setOwningTarget(getOwningTarget());
property.init();
property.setFile(_deliveryList);
property.perform();
}
private void appendDeliveryList(String msg) {
Echo echo = (Echo)getProject().createTask("echo");
echo.setOwningTarget(getOwningTarget());
echo.init();
echo.setFile(_deliveryList);
echo.setMessage(msg+"${line.separator}");
echo.setAppend(true);
echo.perform();
}
}

View File

@ -0,0 +1,185 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.filters.LineContainsRegExp;
import org.apache.tools.ant.filters.TokenFilter;
import org.apache.tools.ant.taskdefs.Concat;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.FilterChain;
import org.apache.tools.ant.types.RegularExpression;
import fr.jayasoft.ivy.ModuleRevisionId;
/**
* Extracts imports from a set of java sources and generate corresponding
* ivy file
*
* @author Hanin
*
*/
public class IvyExtractFromSources extends IvyTask {
public static class Ignore {
String _package;
public String getPackage() {
return _package;
}
public void setPackage(String package1) {
_package = package1;
}
}
private String _organisation;
private String _module;
private String _revision;
private String _status;
private List _ignoredPackaged = new ArrayList(); // List (String package)
private Map _mapping = new HashMap(); // Map (String package -> ModuleRevisionId)
private Concat _concat = new Concat();
private File _to;
public void addConfiguredIgnore(Ignore ignore) {
_ignoredPackaged.add(ignore.getPackage());
}
public File getTo() {
return _to;
}
public void setTo(File to) {
_to = to;
}
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public String getRevision() {
return _revision;
}
public void setRevision(String revision) {
_revision = revision;
}
public String getStatus() {
return _status;
}
public void setStatus(String status) {
_status = status;
}
public void addConfiguredMapping(PackageMapping mapping) {
_mapping.put(mapping.getPackage(), mapping.getModuleRevisionId());
}
public void addFileSet(FileSet fileSet) {
_concat.addFileset(fileSet);
}
public void execute() throws BuildException {
configureConcat();
Writer out = new StringWriter();
_concat.setWriter(out);
_concat.execute();
Set importsSet = new HashSet(Arrays.asList(out.toString().split("\n")));
Set dependencies = new HashSet();
for (Iterator iter = importsSet.iterator(); iter.hasNext();) {
String pack = ((String)iter.next()).trim();
ModuleRevisionId mrid = getMapping(pack);
if (mrid != null) {
dependencies.add(mrid);
}
}
try {
PrintWriter writer = new PrintWriter(new FileOutputStream(_to));
writer.println("<ivy-module version=\"1.0\">");
writer.println("\t<info organisation=\""+_organisation+"\"");
writer.println("\t module=\""+_module+"\"");
if (_revision != null) {
writer.println("\t revision=\""+_revision+"\"");
}
if (_status != null) {
writer.println("\t status=\""+_status+"\"");
} else {
writer.println("\t status=\"integration\"");
}
writer.println("\t/>");
if (!dependencies.isEmpty()) {
writer.println("\t<dependencies>");
for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
ModuleRevisionId mrid = (ModuleRevisionId)iter.next();
writer.println("\t\t<dependency org=\""+mrid.getOrganisation()+"\" name=\""+mrid.getName()+"\" rev=\""+mrid.getRevision()+"\"/>");
}
writer.println("\t</dependencies>");
}
writer.println("</ivy-module>");
writer.close();
log(dependencies.size()+" dependencies put in "+_to);
} catch (FileNotFoundException e) {
throw new BuildException("impossible to create file "+_to);
}
}
/**
* @param pack
* @return
*/
private ModuleRevisionId getMapping(String pack) {
String askedPack = pack;
ModuleRevisionId ret = null;
while (ret == null && pack.length() > 0) {
if (_ignoredPackaged.contains(pack)) {
return null;
}
ret = (ModuleRevisionId)_mapping.get(pack);
int lastDotIndex = pack.lastIndexOf('.');
if (lastDotIndex != -1) {
pack = pack.substring(0, lastDotIndex);
} else {
break;
}
}
if (ret == null) {
log("no mapping found for "+askedPack, Project.MSG_VERBOSE);
}
return ret;
}
private void configureConcat() {
_concat.setProject(getProject());
_concat.setTaskName(getTaskName());
FilterChain filterChain = new FilterChain();
LineContainsRegExp lcre = new LineContainsRegExp();
RegularExpression regexp = new RegularExpression();
regexp.setPattern("^import .+;");
lcre.addConfiguredRegexp(regexp);
filterChain.add(lcre);
TokenFilter tf = new TokenFilter();
TokenFilter.ReplaceRegex rre = new TokenFilter.ReplaceRegex();
rre.setPattern("import (.+);.*");
rre.setReplace("\\1");
tf.add(rre);
filterChain.add(tf);
_concat.addFilterChain(filterChain);
}
}

View File

@ -0,0 +1,220 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Echo;
import org.apache.tools.ant.taskdefs.Property;
import fr.jayasoft.ivy.Artifact;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleRevisionId;
import fr.jayasoft.ivy.util.IvyPatternHelper;
import fr.jayasoft.ivy.util.Message;
/**
* @author Hanin
*
*/
public class IvyPublish extends IvyTask {
private String _organisation;
private String _module;
private String _revision;
private String _pubRevision;
private File _cache;
private String _deliverivypattern;
private String _status;
private String _pubdate;
private String _deliverTarget;
private String _publishResolverName = null;
private String _artifactspattern = null;
private File _deliveryList;
private boolean _publishivy = true;
private boolean _warnonmissing = true;
private boolean _haltonmissing = true;
public File getCache() {
return _cache;
}
public void setCache(File cache) {
_cache = cache;
}
public String getDeliverivypattern() {
return _deliverivypattern;
}
public void setDeliverivypattern(String destivypattern) {
_deliverivypattern = destivypattern;
}
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public String getPubdate() {
return _pubdate;
}
public void setPubdate(String pubdate) {
_pubdate = pubdate;
}
public String getPubrevision() {
return _pubRevision;
}
public void setPubrevision(String pubRevision) {
_pubRevision = pubRevision;
}
public String getRevision() {
return _revision;
}
public void setRevision(String revision) {
_revision = revision;
}
public String getStatus() {
return _status;
}
public void setStatus(String status) {
_status = status;
}
public void setDelivertarget(String deliverTarget) {
_deliverTarget = deliverTarget;
}
public void setDeliveryList(File deliveryList) {
_deliveryList = deliveryList;
}
public String getResolver() {
return _publishResolverName;
}
public void setResolver(String publishResolverName) {
_publishResolverName = publishResolverName;
}
public String getArtifactspattern() {
return _artifactspattern;
}
public void setArtifactspattern(String artifactsPattern) {
_artifactspattern = artifactsPattern;
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
_organisation = getProperty(_organisation, ivy, "ivy.organisation");
_module = getProperty(_module, ivy, "ivy.module");
_revision = getProperty(_revision, ivy, "ivy.revision");
_pubRevision = getProperty(_pubRevision, ivy, "ivy.deliver.revision");
if (_cache == null) {
_cache = ivy.getDefaultCache();
}
_artifactspattern = getProperty(_artifactspattern, ivy, "ivy.publish.src.artifacts.pattern");
if (_deliverivypattern == null) {
_deliverivypattern = _artifactspattern;
}
_status = getProperty(_status, ivy, "ivy.status");
if (_module == null || _organisation == null || _revision == null) {
throw new BuildException("empty or incomplete module revision id provided for publish: either call resolve, give paramaters to publish, or provide ivy.module, ivy.organisation and ivy.revision properties");
}
if (_artifactspattern == null) {
throw new BuildException("no artifacts pattern: either provide it through parameter or through ivy.publish.src.artifacts.pattern property");
}
if (_publishResolverName == null) {
throw new BuildException("no publish deliver name: please provide it through parameter 'resolver'");
}
Date pubdate = getPubDate(_pubdate, new Date());
if (_pubRevision == null) {
if (_revision.startsWith("working@")) {
_pubRevision = Ivy.DATE_FORMAT.format(pubdate);
} else {
_pubRevision = _revision;
}
}
if (_status == null) {
throw new BuildException("no status provided: either provide it as parameter or through the ivy.status.default property");
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
try {
File ivyFile = new File(_cache, IvyPatternHelper.substitute(_deliverivypattern, _organisation, _module, _pubRevision, "ivy", "ivy", "xml"));
if (_publishivy && !ivyFile.exists()) {
IvyDeliver deliver = new IvyDeliver();
deliver.setProject(getProject());
deliver.setCache(getCache());
deliver.setDeliverpattern(getDeliverivypattern());
deliver.setDelivertarget(_deliverTarget);
deliver.setDeliveryList(_deliveryList);
deliver.setModule(getModule());
deliver.setOrganisation(getOrganisation());
deliver.setPubdate(Ivy.DATE_FORMAT.format(pubdate));
deliver.setPubrevision(getPubrevision());
deliver.setRevision(getRevision());
deliver.setStatus(getStatus());
deliver.setValidate(doValidate(ivy));
deliver.execute();
}
Collection missing = ivy.publish(mrid, _pubRevision, _cache, _artifactspattern, _publishResolverName, _publishivy, doValidate(ivy));
if (_warnonmissing) {
for (Iterator iter = missing.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact)iter.next();
Message.warn("missing artifact: "+artifact);
}
}
if (_haltonmissing && !missing.isEmpty()) {
throw new BuildException("missing published artifacts for "+mrid+": "+missing);
}
} catch (Exception e) {
e.printStackTrace();
throw new BuildException("impossible to publish artifacts for "+mrid+": "+e.getMessage(), e);
}
}
private void loadDeliveryList() {
Property property = (Property)getProject().createTask("property");
property.setOwningTarget(getOwningTarget());
property.init();
property.setFile(_deliveryList);
property.perform();
}
private void appendDeliveryList(String msg) {
Echo echo = (Echo)getProject().createTask("echo");
echo.setOwningTarget(getOwningTarget());
echo.init();
echo.setFile(_deliveryList);
echo.setMessage(msg+"\n");
echo.setAppend(true);
echo.perform();
}
public boolean isPublishivy() {
return _publishivy;
}
public void setPublishivy(boolean publishivy) {
_publishivy = publishivy;
}
public boolean isWarnonmissing() {
return _warnonmissing;
}
public void setWarnonmissing(boolean warnonmissing) {
_warnonmissing = warnonmissing;
}
public boolean isHaltonmissing() {
return _haltonmissing;
}
public void setHaltonmissing(boolean haltonmissing) {
_haltonmissing = haltonmissing;
}
}

View File

@ -0,0 +1,202 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.XSLTProcess;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleId;
import fr.jayasoft.ivy.report.XmlReportOutputter;
import fr.jayasoft.ivy.util.FileUtil;
import fr.jayasoft.ivy.util.IvyPatternHelper;
import fr.jayasoft.ivy.util.Message;
public class IvyReport extends IvyTask {
private File _todir;
private String _organisation;
private String _module;
private String _conf;
private File _cache;
private boolean _graph = true;
private String _xslFile;
private String _outputpattern;
public File getTodir() {
return _todir;
}
public void setTodir(File todir) {
_todir = todir;
}
public File getCache() {
return _cache;
}
public void setCache(File cache) {
_cache = cache;
}
public String getConf() {
return _conf;
}
public void setConf(String conf) {
_conf = conf;
}
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public boolean isGraph() {
return _graph;
}
public void setGraph(boolean graph) {
_graph = graph;
}
public String getXslfile() {
return _xslFile;
}
public void setXslfile(String xslFile) {
_xslFile = xslFile;
}
public String getOutputpattern() {
return _outputpattern;
}
public void setOutputpattern(String outputpattern) {
_outputpattern = outputpattern;
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
_organisation = getProperty(_organisation, ivy, "ivy.organisation");
_module = getProperty(_module, ivy, "ivy.module");
if (_cache == null) {
_cache = ivy.getDefaultCache();
}
_conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
if (_conf.equals("*")) {
_conf = getProperty(ivy, "ivy.resolved.configurations");
}
if (_todir == null) {
String t = getProperty(ivy, "ivy.report.todir");
if (t != null) {
_todir = new File(t);
}
}
_outputpattern = getProperty(_outputpattern, ivy, "ivy.report.output.pattern");
if (_todir != null && _todir.exists()) {
_todir.mkdirs();
}
if (_outputpattern == null) {
_outputpattern = "[organisation]-[module]-[conf].html";
}
if (!_todir.isDirectory()) {
throw new BuildException("destination directory should be a directory !");
}
if (_organisation == null || _module == null) {
throw new BuildException("no module id provided for retrieve: either call resolve, give paramaters to ivy:retrieve, or provide ivy.module and ivy.organisation properties");
}
try {
String[] confs = splitConfs(_conf);
for (int i = 0; i < confs.length; i++) {
genreport(ivy, _cache, _organisation, _module, confs[i]);
if (_graph) {
gengraph(ivy, _cache, _organisation, _module, confs[i]);
}
}
} catch (IOException e) {
throw new BuildException("impossible to generate report", e);
}
}
private void genreport(Ivy ivy, File cache, String organisation, String module, String conf) throws IOException {
// first process the report with xslt
XSLTProcess xslt = new XSLTProcess();
xslt.setTaskName(getTaskName());
xslt.setProject(getProject());
xslt.setIn(new File(cache, XmlReportOutputter.getReportFileName(new ModuleId(organisation, module), conf)));
File out;
if (_todir != null) {
out = new File(_todir, IvyPatternHelper.substitute(_outputpattern, organisation, module, "", "", "", "", conf));
} else {
out = new File(IvyPatternHelper.substitute(_outputpattern, organisation, module, "", "", "", "", conf));
}
if (out.getParentFile() != null && !out.getParentFile().exists()) {
out.getParentFile().mkdirs();
}
xslt.setOut(out);
xslt.setStyle(getReportStylePath(cache));
XSLTProcess.Param param = xslt.createParam();
param.setName("confs");
param.setExpression(_conf);
param = xslt.createParam();
param.setName("extension");
param.setExpression("html");
xslt.execute();
// then copy the css if required
if (_todir != null && _xslFile == null) {
File css = new File(_todir, "ivy-report.css");
if (!css.exists()) {
Message.debug("copying report css to "+_todir);
FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.css"), css, null);
}
FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.css"), new File(cache, "ivy-report.css"), null);
}
}
private String getReportStylePath(File cache) throws IOException {
if (_xslFile != null) {
return _xslFile;
}
// style should be a file (and not an url)
// so we have to copy it from classpath to cache
File style = new File(cache, "ivy-report.xsl");
FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.xsl"), style, null);
return style.getAbsolutePath();
}
private void gengraph(Ivy ivy, File cache, String organisation, String module, String conf) throws IOException {
// process the report with xslt to generate graphml
XSLTProcess xslt = new XSLTProcess();
xslt.setTaskName(getTaskName());
xslt.setProject(getProject());
xslt.setDestdir(_todir);
xslt.setBasedir(cache);
xslt.setExtension(".graphml");
xslt.setIncludes(XmlReportOutputter.getReportFileName(new ModuleId(organisation, module), conf));
xslt.setStyle(getGraphStylePath(cache));
xslt.execute();
}
private String getGraphStylePath(File cache) throws IOException {
// style should be a file (and not an url)
// so we have to copy it from classpath to cache
File style = new File(cache, "ivy-report-graph.xsl");
FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report-graph.xsl"), style, null);
return style.getAbsolutePath();
}
}

View File

@ -0,0 +1,108 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.net.MalformedURLException;
import java.text.ParseException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleDescriptor;
import fr.jayasoft.ivy.report.ResolveReport;
import fr.jayasoft.ivy.util.Message;
/**
* @author Hanin
*
*/
public class IvyResolve extends IvyTask {
private File _file = null;
private String _conf = null;
private File _cache = null;
private String _revision = null;
private String _pubdate = null;
private boolean _haltOnFailure = true;
public String getDate() {
return _pubdate;
}
public void setDate(String pubdate) {
_pubdate = pubdate;
}
public String getRevision() {
return _revision;
}
public void setRevision(String revision) {
_revision = revision;
}
public File getCache() {
return _cache;
}
public void setCache(File cache) {
_cache = cache;
}
public String getConf() {
return _conf;
}
public void setConf(String conf) {
_conf = conf;
}
public File getFile() {
return _file;
}
public void setFile(File file) {
_file = file;
}
public boolean isHaltonfailure() {
return _haltOnFailure;
}
public void setHaltonfailure(boolean haltOnFailure) {
_haltOnFailure = haltOnFailure;
}
public void setShowprogress(boolean show) {
Message.setShowProgress(show);
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
try {
if (_file == null) {
_file = new File(getProject().getBaseDir(), getProperty(ivy, "ivy.dep.file"));
}
_conf = getProperty(_conf, ivy, "ivy.configurations");
_revision = getProperty(_revision, ivy, "ivy.revision");
if (_cache == null) {
_cache = ivy.getDefaultCache();
}
String[] confs = splitConfs(_conf);
ResolveReport report = ivy.resolve(_file.toURL(), _revision, confs, _cache, getPubDate(_pubdate, null), doValidate(ivy));
if (isHaltonfailure() && report.hasError()) {
throw new BuildException("resolve failed - see output for details");
}
ModuleDescriptor md = report.getModuleDescriptor();
setResolved(md);
getProject().setProperty("ivy.organisation", md.getModuleRevisionId().getOrganisation());
getProject().setProperty("ivy.module", md.getModuleRevisionId().getName());
getProject().setProperty("ivy.revision", md.getResolvedModuleRevisionId().getRevision());
if (_conf.trim().equals("*")) {
getProject().setProperty("ivy.resolved.configurations", mergeConfs(md.getConfigurationsNames()));
} else {
getProject().setProperty("ivy.resolved.configurations", _conf);
}
} catch (MalformedURLException e) {
throw new BuildException("unable to convert given ivy file to url: "+_file, e);
} catch (ParseException e) {
log(e.getMessage(), Project.MSG_ERR);
throw new BuildException("syntax errors in ivy file", e);
} catch (Exception e) {
throw new BuildException("impossible to resolve dependencies: "+e.getMessage(), e);
}
}
}

View File

@ -0,0 +1,89 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleId;
import java.io.File;
import org.apache.tools.ant.BuildException;
/**
* @author Hanin
*
*/
public class IvyRetrieve extends IvyTask {
private String _organisation;
private String _module;
private String _conf;
private File _cache;
private String _pattern;
private boolean _haltOnFailure = true;
public File getCache() {
return _cache;
}
public void setCache(File cache) {
_cache = cache;
}
public String getConf() {
return _conf;
}
public void setConf(String conf) {
_conf = conf;
}
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public String getPattern() {
return _pattern;
}
public void setPattern(String pattern) {
_pattern = pattern;
}
public boolean isHaltonfailure() {
return _haltOnFailure;
}
public void setHaltonfailure(boolean haltOnFailure) {
_haltOnFailure = haltOnFailure;
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
ensureResolved(isHaltonfailure());
_organisation = getProperty(_organisation, ivy, "ivy.organisation");
_module = getProperty(_module, ivy, "ivy.module");
if (_cache == null) {
_cache = ivy.getDefaultCache();
}
_pattern = getProperty(_pattern, ivy, "ivy.retrieve.pattern");
_conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
if (_conf.equals("*")) {
_conf = getProperty(ivy, "ivy.resolved.configurations");
}
if (_organisation == null || _module == null) {
throw new BuildException("no module id provided for retrieve: either call resolve, give paramaters to ivy:retrieve, or provide ivy.module and ivy.organisation properties");
}
try {
ivy.retrieve(new ModuleId(_organisation, _module), splitConfs(_conf), _cache, _pattern);
} catch (Exception ex) {
throw new BuildException("impossible to ivy retrieve: "+ex.getMessage(), ex);
}
}
}

View File

@ -0,0 +1,126 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleDescriptor;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* @author Hanin
*
*/
public class IvyTask extends Task {
private Boolean _validate = null;
protected boolean doValidate(Ivy ivy) {
if (_validate != null) {
return _validate.booleanValue();
}
return ivy.doValidate();
}
public boolean isValidate() {
return _validate == null ? true : _validate.booleanValue();
}
public void setValidate(boolean validate) {
_validate = Boolean.valueOf(validate);
}
protected Ivy getIvyInstance() {
Object reference = getProject().getReference("ivy.instance");
if (reference == null) {
IvyConfigure configure = new IvyConfigure();
configure.setProject(getProject());
configure.execute();
reference = getProject().getReference("ivy.instance");
if (reference == null) {
throw new BuildException("ivy internal problem: impossible to get ivy instance !");
}
}
if (! (reference instanceof Ivy)) {
throw new BuildException("ivy internal problem: bad ivy instance class: "+reference.getClass());
}
return (Ivy)reference;
}
protected void setIvyInstance(Ivy ivy) {
getProject().addReference("ivy.instance", ivy);
}
protected void setResolved(ModuleDescriptor md) {
getProject().addReference("ivy.resolved.descriptor", md);
}
protected void ensureResolved(boolean haltOnFailure) {
Object reference = getProject().getReference("ivy.resolved.descriptor");
if (reference == null) {
IvyResolve resolve = new IvyResolve();
resolve.setProject(getProject());
resolve.setHaltonfailure(haltOnFailure);
if (_validate != null) {
resolve.setValidate(_validate.booleanValue());
}
resolve.execute();
}
}
protected String[] splitConfs(String conf) {
String[] confs = conf.split(",");
for (int i = 0; i < confs.length; i++) {
confs[i] = confs[i].trim();
}
return confs;
}
protected String mergeConfs(String[] conf) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < conf.length; i++) {
buf.append(conf[i]).append(", ");
}
if (conf.length > 0) {
buf.setLength(buf.length() - 2); // delete last comma
}
return buf.toString();
}
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
protected Date getPubDate(String date, Date def) {
if (date != null) {
if ("now".equalsIgnoreCase(date)) {
return new Date();
}
try {
return DATE_FORMAT.parse(date);
} catch (Exception ex) {
throw new BuildException("publication date provided in bad format. should be yyyyMMddHHmmss and not "+date);
}
} else {
return def;
}
}
protected String getProperty(String value, Ivy ivy, String name) {
if (value == null) {
return getProperty(ivy, name);
} else {
return ivy.substitute(value);
}
}
protected String getProperty(Ivy ivy, String name) {
String val = ivy.getVariable(name);
val = val == null ? getProject().getProperty(name) : val;
return val == null ? null : ivy.substitute(val);
}
}

View File

@ -0,0 +1,121 @@
/*
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
* Copyright Jayasoft 2005 - All rights reserved
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import java.util.Properties;
import org.apache.tools.ant.BuildException;
import fr.jayasoft.ivy.Ivy;
public class IvyVar extends IvyTask {
private String _name;
private String _value;
private File _file;
private String _url;
private String _prefix;
public File getFile() {
return _file;
}
public void setFile(File file) {
_file = file;
}
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
public String getPrefix() {
return _prefix;
}
public void setPrefix(String prefix) {
_prefix = prefix;
}
public String getUrl() {
return _url;
}
public void setUrl(String url) {
_url = url;
}
public String getValue() {
return _value;
}
public void setValue(String value) {
_value = value;
}
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
if (getName() != null) {
ivy.setVariable(getVarName(getName()), getValue());
} else {
Properties props = new Properties();
InputStream is = null;
try {
if (getFile() != null) {
is = new FileInputStream(getFile());
} else if (getUrl() != null) {
is = new URL(getUrl()).openStream();
} else {
throw new BuildException("specify either name or file or url to ivy var task");
}
props.load(is);
} catch (Exception ex) {
throw new BuildException("impossible to load variables from file", ex);
} finally {
if (is != null) {
try {is.close();} catch (Exception e) {}
}
}
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
String name = (String)iter.next();
String value = (String)props.get(name);
ivy.setVariable(getVarName(name), value);
}
}
}
private String getVarName(String name) {
String prefix = getPrefix();
if (prefix != null) {
if (prefix.endsWith(".")) {
return prefix + name;
} else {
return prefix + "." + name;
}
}
return name;
}
}

View File

@ -0,0 +1,48 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.ant;
import fr.jayasoft.ivy.ModuleRevisionId;
/**
* @author Hanin
*
*/
public class PackageMapping {
private String _package;
private String _organisation;
private String _module;
private String _revision;
public String getModule() {
return _module;
}
public void setModule(String module) {
_module = module;
}
public String getOrganisation() {
return _organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
}
public String getRevision() {
return _revision;
}
public void setRevision(String revision) {
_revision = revision;
}
public String getPackage() {
return _package;
}
public void setPackage(String package1) {
_package = package1;
}
public ModuleRevisionId getModuleRevisionId() {
return ModuleRevisionId.newInstance(_organisation, _module, _revision);
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<antlib xmlns:current="ant:current">
<taskdef name="configure" classname="fr.jayasoft.ivy.ant.IvyConfigure"/>
<taskdef name="resolve" classname="fr.jayasoft.ivy.ant.IvyResolve"/>
<taskdef name="retrieve" classname="fr.jayasoft.ivy.ant.IvyRetrieve"/>
<taskdef name="deliver" classname="fr.jayasoft.ivy.ant.IvyDeliver"/>
<taskdef name="publish" classname="fr.jayasoft.ivy.ant.IvyPublish"/>
<taskdef name="extract" classname="fr.jayasoft.ivy.ant.IvyExtractFromSources"/>
<taskdef name="cachepath" classname="fr.jayasoft.ivy.ant.IvyCachePath"/>
<taskdef name="report" classname="fr.jayasoft.ivy.ant.IvyReport"/>
<taskdef name="var" classname="fr.jayasoft.ivy.ant.IvyVar"/>
<taskdef name="check" classname="fr.jayasoft.ivy.ant.IvyCheck"/>
<taskdef name="artifactproperty" classname="fr.jayasoft.ivy.ant.IvyArtifactProperty"/>
</antlib>

View File

@ -0,0 +1,15 @@
ivy.project.dir = ${basedir}
ivy.lib.dir = ${ivy.project.dir}/lib
ivy.build.artifacts.dir = ${ivy.project.dir}/build/artifacts
ivy.distrib.dir = ${ivy.project.dir}/distrib
ivy.configurations = *
ivy.resolver.default.check.modified = false
ivy.status = integration
ivy.dep.file = ivy.xml
ivy.conf.file = ivyconf.xml
ivy.retrieve.pattern = ${ivy.lib.dir}/[artifact]-[revision].[ext]
ivy.deliver.ivy.pattern = ${ivy.distrib.dir}/[type]s/[artifact]-[revision].[ext]
ivy.publish.src.artifacts.pattern = ${ivy.distrib.dir}/[type]s/[artifact]-[revision].[ext]
ivy.report.output.pattern = [organisation]-[module]-[conf].html

View File

@ -0,0 +1,35 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.conflict;
import fr.jayasoft.ivy.ConflictManager;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.IvyAware;
public abstract class AbstractConflictManager implements ConflictManager, IvyAware {
private String _name;
private Ivy _ivy;
public Ivy getIvy() {
return _ivy;
}
public void setIvy(Ivy ivy) {
_ivy = ivy;
}
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
public String toString() {
return _name;
}
}

View File

@ -0,0 +1,37 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.conflict;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import fr.jayasoft.ivy.IvyNode;
public class FixedConflictManager extends AbstractConflictManager {
private Collection _revs;
public FixedConflictManager(String[] revs) {
_revs = Arrays.asList(revs);
setName("fixed"+_revs);
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
Collection resolved = new ArrayList(conflicts.size());
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode)iter.next();
String revision = node.getResolvedId().getRevision();
if (_revs.contains(revision)) {
resolved.add(node);
}
}
return resolved;
}
public Collection getRevs() {
return _revs;
}
}

View File

@ -0,0 +1,115 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.conflict;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import fr.jayasoft.ivy.ArtifactInfo;
import fr.jayasoft.ivy.DependencyDescriptor;
import fr.jayasoft.ivy.IvyNode;
import fr.jayasoft.ivy.LatestStrategy;
import fr.jayasoft.ivy.util.Message;
public class LatestConflictManager extends AbstractConflictManager {
private static class IvyNodeArtifactInfo implements ArtifactInfo {
private final IvyNode _node;
private IvyNodeArtifactInfo(IvyNode dep) {
_node = dep;
}
public long getLastModified() {
return _node.getPublication();
}
public String getRevision() {
return _node.getId().getRevision();
}
public IvyNode getNode() {
return _node;
}
}
private LatestStrategy _strategy;
private String _strategyName;
public LatestConflictManager() {
}
public LatestConflictManager(LatestStrategy strategy) {
_strategy = strategy;
}
public LatestConflictManager(String name, LatestStrategy strategy) {
setName(name);
_strategy = strategy;
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode)iter.next();
DependencyDescriptor dd = node.getDependencyDescriptor();
if (dd != null && dd.isForce() && parent.getResolvedId().equals(dd.getParentRevisionId())) {
return Collections.singleton(node);
}
}
ArtifactInfo latest = getStrategy().findLatest(toArtifactInfo(conflicts), null);
if (latest != null) {
return Collections.singleton(((IvyNodeArtifactInfo)latest).getNode());
} else {
return conflicts;
}
}
private ArtifactInfo[] toArtifactInfo(Collection conflicts) {
List artifacts = new ArrayList(conflicts.size());
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode)iter.next();
artifacts.add(new IvyNodeArtifactInfo(node));
}
return (ArtifactInfo[])artifacts.toArray(new ArtifactInfo[artifacts.size()]);
}
public LatestStrategy getStrategy() {
if (_strategy == null) {
if (_strategyName != null) {
_strategy = getIvy().getLatestStrategy(_strategyName);
if (_strategy == null) {
Message.error("unknown latest strategy: "+_strategyName);
_strategy = getIvy().getDefaultLatestStrategy();
}
} else {
_strategy = getIvy().getDefaultLatestStrategy();
}
}
return _strategy;
}
/**
* To conform to configurator API
* @param latestStrategy
*/
public void setLatest(String strategyName) {
_strategyName = strategyName;
}
public void setStrategy(LatestStrategy strategy) {
_strategy = strategy;
}
public String toString() {
return String.valueOf(_strategy);
}
}

View File

@ -0,0 +1,19 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.conflict;
import java.util.Collection;
import fr.jayasoft.ivy.IvyNode;
public class NoConflictManager extends AbstractConflictManager {
public NoConflictManager() {
setName("all");
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
return conflicts;
}
}

View File

@ -0,0 +1,6 @@
<ivyconf>
<conf defaultResolver="ivyrep"/>
<resolvers>
<ivyrep name="ivyrep"/>
</resolvers>
</ivyconf>

View File

@ -0,0 +1,36 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.latest;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.IvyAware;
import fr.jayasoft.ivy.LatestStrategy;
public abstract class AbstractLatestStrategy implements LatestStrategy, IvyAware {
private String _name;
private Ivy _ivy;
public Ivy getIvy() {
return _ivy;
}
public void setIvy(Ivy ivy) {
_ivy = ivy;
}
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
public String toString() {
return _name;
}
}

View File

@ -0,0 +1,67 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.latest;
import java.util.Comparator;
import java.util.Date;
import fr.jayasoft.ivy.ArtifactInfo;
public class LatestLexicographicStrategy extends AbstractLatestStrategy {
/**
* Compares two revisions.
* Revisions are compared lexicographically unless
* a 'latest' revision is found. If the latest revision found
* is an absolute latest (latest. like), then it is assumed to be the greater.
* If a partial latest is found, then it is assumed to be greater
* than any matching fixed revision.
*/
private static Comparator COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
String rev1 = (String)o1;
String rev2 = (String)o2;
if (rev1.startsWith("latest")) {
return 1;
}
if (rev1.endsWith("+") && rev2.startsWith(rev1.substring(0, rev1.length() - 1))) {
return 1;
}
if (rev2.startsWith("latest")) {
return -1;
}
if (rev2.endsWith("+") && rev1.startsWith(rev2.substring(0, rev2.length() - 1))) {
return -1;
}
return rev1.compareTo(rev2);
}
};
public LatestLexicographicStrategy() {
setName("latest-lexico");
}
public ArtifactInfo findLatest(ArtifactInfo[] artifacts, Date date) {
if (artifacts == null) {
return null;
}
ArtifactInfo found = null;
for (int i = 0; i < artifacts.length; i++) {
ArtifactInfo art = artifacts[i];
if (found == null || COMPARATOR.compare(art.getRevision(), found.getRevision()) > 0) {
if (date != null) {
long lastModified = art.getLastModified();
if (lastModified > date.getTime()) {
continue;
}
}
found = art;
}
}
return found;
}
}

View File

@ -0,0 +1,125 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.latest;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import fr.jayasoft.ivy.ArtifactInfo;
public class LatestRevisionStrategy extends AbstractLatestStrategy {
private static final Map SPECIAL_MEANINGS;
static {
SPECIAL_MEANINGS = new HashMap();
SPECIAL_MEANINGS.put("dev", new Integer(-1));
SPECIAL_MEANINGS.put("rc", new Integer(1));
SPECIAL_MEANINGS.put("final", new Integer(2));
}
/**
* Compares two revisions.
* Revisions are compared using an algorithm inspired by PHP
* version_compare one, unless
* a 'latest' revision is found. If the latest revision found
* is an absolute latest (latest. like), then it is assumed to be the greater.
* If a partial latest is found, then it is assumed to be greater
* than any matching fixed revision.
*/
public static Comparator COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
String rev1 = (String)o1;
String rev2 = (String)o2;
if (rev1.startsWith("latest")) {
return 1;
}
if (rev1.endsWith("+") && rev2.startsWith(rev1.substring(0, rev1.length() - 1))) {
return 1;
}
if (rev2.startsWith("latest")) {
return -1;
}
if (rev2.endsWith("+") && rev1.startsWith(rev2.substring(0, rev2.length() - 1))) {
return -1;
}
rev1 = rev1.replaceAll("([a-zA-Z])(\\d)", "$1.$2");
rev1 = rev1.replaceAll("(\\d)([a-zA-Z])", "$1.$2");
rev2 = rev2.replaceAll("([a-zA-Z])(\\d)", "$1.$2");
rev2 = rev2.replaceAll("(\\d)([a-zA-Z])", "$1.$2");
String[] parts1 = rev1.split("[\\._\\-\\+]");
String[] parts2 = rev2.split("[\\._\\-\\+]");
int i = 0;
for (; i < parts1.length && i <parts2.length; i++) {
if (parts1[i].equals(parts2[i])) {
continue;
}
boolean is1Number = isNumber(parts1[i]);
boolean is2Number = isNumber(parts2[i]);
if (is1Number && !is2Number) {
return 1;
}
if (is2Number && !is1Number) {
return -1;
}
if (is1Number && is2Number) {
return Long.valueOf(parts1[i]).compareTo(Long.valueOf(parts2[i]));
}
// both are strings, we compare them taking into account special meaning
Integer sm1 = (Integer)SPECIAL_MEANINGS.get(parts1[i].toLowerCase());
Integer sm2 = (Integer)SPECIAL_MEANINGS.get(parts2[i].toLowerCase());
if (sm1 != null) {
sm2 = sm2==null?new Integer(0):sm2;
return sm1.compareTo(sm2);
}
if (sm2 != null) {
return new Integer(0).compareTo(sm2);
}
return parts1[i].compareTo(parts2[i]);
}
if (i < parts1.length) {
return isNumber(parts1[i])?1:-1;
}
if (i < parts2.length) {
return isNumber(parts2[i])?-1:1;
}
return 0;
}
private boolean isNumber(String str) {
return str.matches("\\d+");
}
};
public LatestRevisionStrategy() {
setName("latest-revision");
}
public ArtifactInfo findLatest(ArtifactInfo[] artifacts, Date date) {
if (artifacts == null) {
return null;
}
ArtifactInfo found = null;
for (int i = 0; i < artifacts.length; i++) {
ArtifactInfo art = artifacts[i];
if (found == null || COMPARATOR.compare(art.getRevision(), found.getRevision()) > 0) {
if (date != null) {
long lastModified = art.getLastModified();
if (lastModified > date.getTime()) {
continue;
}
}
found = art;
}
}
return found;
}
}

View File

@ -0,0 +1,33 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.latest;
import java.util.Date;
import fr.jayasoft.ivy.ArtifactInfo;
public class LatestTimeStrategy extends AbstractLatestStrategy {
public LatestTimeStrategy() {
setName("latest-time");
}
public ArtifactInfo findLatest(ArtifactInfo[] artifacts, Date date) {
if (artifacts == null) {
return null;
}
ArtifactInfo found = null;
long foundDate = 0;
for (int i = 0; i < artifacts.length; i++) {
ArtifactInfo art = artifacts[i];
long lastModified = art.getLastModified();
if (lastModified > foundDate && (date == null || lastModified <= date.getTime())) {
foundDate = lastModified;
found = art;
}
}
return found;
}
}

View File

@ -0,0 +1,48 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.report;
import fr.jayasoft.ivy.Artifact;
/**
* @author x.hanin
*
*/
public class ArtifactDownloadReport {
private Artifact _artifact;
private DownloadStatus _downloadStatus;
private long _size;
public ArtifactDownloadReport(Artifact artifact) {
_artifact = artifact;
}
public DownloadStatus getDownloadStatus() {
return _downloadStatus;
}
public void setDownloadStatus(DownloadStatus downloadStatus) {
_downloadStatus = downloadStatus;
}
public String getName() {
return _artifact.getName();
}
public String getType() {
return _artifact.getType();
}
public Artifact getArtifact() {
return _artifact;
}
public String getExt() {
return _artifact.getExt();
}
public long getSize() {
return _size;
}
public void setSize(long size) {
_size = size;
}
}

Some files were not shown because too many files have changed in this diff Show More