Merge branch 'master' into xooki2asciidoc

This commit is contained in:
Nicolas Lalevée 2017-05-25 15:04:39 +02:00
commit 5d6131a301
300 changed files with 5488 additions and 3321 deletions

View File

@ -1,45 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/ant.jar"/>
<classpathentry kind="lib" path="lib/ant-testutil.jar"/>
<classpathentry kind="lib" path="lib/commons-codec.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient.jar"/>
<classpathentry kind="lib" path="lib/commons-lang.jar"/>
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
<classpathentry kind="lib" path="lib/commons-vfs.jar"/>
<classpathentry kind="lib" path="lib/jsch.jar"/>
<classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="lib" path="lib/xmlunit.jar"/>
<classpathentry kind="lib" path="lib/oro.jar"/>
<classpathentry kind="lib" path="lib/bcpg-jdk14.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk14.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.connector-factory.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.core.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.jsch.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.pageant.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.sshagent.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-jna.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-nc.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/ant.jar"/>
<classpathentry kind="lib" path="lib/ant-testutil.jar"/>
<classpathentry kind="lib" path="lib/commons-codec.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient.jar"/>
<classpathentry kind="lib" path="lib/commons-lang.jar"/>
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
<classpathentry kind="lib" path="lib/commons-vfs.jar"/>
<classpathentry kind="lib" path="lib/jsch.jar"/>
<classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="lib" path="lib/xmlunit.jar"/>
<classpathentry kind="lib" path="lib/oro.jar"/>
<classpathentry kind="lib" path="lib/bcpg-jdk15on.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk15on.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.connector-factory.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.core.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.jsch.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.pageant.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.sshagent.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-jna.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-nc.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

2
NOTICE
View File

@ -1,5 +1,5 @@
Apache Ivy (TM)
Copyright 2007-2014 The Apache Software Foundation
Copyright 2007-2017 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

View File

@ -17,102 +17,102 @@
under the License.
-->
<project name="IvyRelease" default="snapshot"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:ivy2="antlib:org.apache.ivy.ant_2"
xmlns:asciidoctor="antlib:org.asciidoctor.ant"
xmlns:openpgp="antlib:org.apache.commons.openpgp.ant">
<import file="build.xml"/>
<macrodef name="run-tutorial">
<attribute name="antfile" />
<attribute name="output" />
<attribute name="target" default="" />
<attribute name="failonerror" default="true" />
<sequential>
<echo>Running @{antfile} @{target} > @{output}</echo>
xmlns:openpgp="antlib:org.apache.commons.openpgp.ant">
<import file="build.xml"/>
<macrodef name="run-tutorial">
<attribute name="antfile" />
<attribute name="output" />
<attribute name="target" default="" />
<attribute name="failonerror" default="true" />
<sequential>
<echo>Running @{antfile} @{target} > @{output}</echo>
<local name="antfile.dir" />
<dirname property="antfile.dir" file="@{antfile}" />
<local name="antfile.name" />
<basename property="antfile.name" file="@{antfile}" />
<echo file="@{output}">[ivy@apache:${antfile.dir}]$ ant -f ${antfile.name} @{target}${line.separator}</echo>
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true"
failonerror="@{failonerror}"
logerror="true"
append="true"
output="@{output}">
<classpath>
<fileset file="${artifacts.build.dir}/jars/${final.name}" />
<!--
We need to set the classpath like this, otherwise the invoked
build scripts are not capable of compiling sources ???
-->
<path path="${java.class.path}" />
</classpath>
<sysproperty key="ivy.cache.dir" value="${tutorial.cache}" />
<sysproperty key="ivy.local.default.root" value="${tutorial.local-repo}" />
<local name="antfile.name" />
<basename property="antfile.name" file="@{antfile}" />
<echo file="@{output}">[ivy@apache:${antfile.dir}]$ ant -f ${antfile.name} @{target}${line.separator}</echo>
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true"
failonerror="@{failonerror}"
logerror="true"
append="true"
output="@{output}">
<classpath>
<fileset file="${artifacts.build.dir}/jars/${final.name}" />
<!--
We need to set the classpath like this, otherwise the invoked
build scripts are not capable of compiling sources ???
-->
<path path="${java.class.path}" />
</classpath>
<sysproperty key="ivy.cache.dir" value="${tutorial.cache}" />
<sysproperty key="ivy.local.default.root" value="${tutorial.local-repo}" />
<sysproperty key="ivy.cache.ttl.default" value="1s" />
<sysproperty key="skip.download" value="true" />
<arg line="-f @{antfile}" />
<arg line="@{target}" />
</java>
</sequential>
</macrodef>
<target name="generate-tutorial-output" depends="jar" unless="skip.generate-tutorial-output">
<sysproperty key="skip.download" value="true" />
<arg line="-f @{antfile}" />
<arg line="@{target}" />
</java>
</sequential>
</macrodef>
<target name="generate-tutorial-output" depends="jar" unless="skip.generate-tutorial-output">
<property name="output.dir" value="${basedir}/asciidoc/tutorial/log" />
<delete dir="${output.dir}" />
<delete dir="${output.dir}" />
<mkdir dir="${output.dir}" />
<!-- create a copy of the tutorials so we can easily get rid of the generated files -->
<property name="tutorial.src.dir" value="${build.dir}/examples" />
<delete dir="${tutorial.src.dir}" />
<mkdir dir="${tutorial.src.dir}" />
<copy todir="${tutorial.src.dir}">
<fileset dir="src/example" />
</copy>
<!-- create a cache and local-repository for the tutorials -->
<property name="tutorial.build.dir" value="${build.dir}/tutorial" />
<property name="tutorial.cache" value="${tutorial.build.dir}/cache" />
<property name="tutorial.local-repo" value="${tutorial.build.dir}/local" />
<!-- go-ivy : not logged, but run in order to check if it still run -->
<run-tutorial antfile="${tutorial.src.dir}/go-ivy/build.xml" output="${output.dir}/dummy.txt" />
<!-- create a copy of the tutorials so we can easily get rid of the generated files -->
<property name="tutorial.src.dir" value="${build.dir}/examples" />
<delete dir="${tutorial.src.dir}" />
<mkdir dir="${tutorial.src.dir}" />
<copy todir="${tutorial.src.dir}">
<fileset dir="src/example" />
</copy>
<!-- create a cache and local-repository for the tutorials -->
<property name="tutorial.build.dir" value="${build.dir}/tutorial" />
<property name="tutorial.cache" value="${tutorial.build.dir}/cache" />
<property name="tutorial.local-repo" value="${tutorial.build.dir}/local" />
<!-- go-ivy : not logged, but run in order to check if it still run -->
<run-tutorial antfile="${tutorial.src.dir}/go-ivy/build.xml" output="${output.dir}/dummy.txt" />
<delete file="${output.dir}/dummy.txt" />
<delete dir="${tutorial.build.dir}" />
<!-- hello-ivy : Quick Start - start.html -->
<run-tutorial antfile="${tutorial.src.dir}/hello-ivy/build.xml" output="${output.dir}/hello-ivy-1.txt" />
<run-tutorial antfile="${tutorial.src.dir}/hello-ivy/build.xml" output="${output.dir}/hello-ivy-2.txt" />
<delete dir="${tutorial.build.dir}" />
<!-- multiple resolvers - multiple.html -->
<!-- multiple resolvers - multiple.html -->
<run-tutorial antfile="${tutorial.src.dir}/chained-resolvers/chainedresolvers-project/build.xml" output="${output.dir}/chained-resolvers.txt" />
<delete dir="${tutorial.build.dir}" />
<!-- dual - dual.html -->
<!-- dual - dual.html -->
<run-tutorial antfile="${tutorial.src.dir}/dual/project/build.xml" output="${output.dir}/dual.txt" />
<delete dir="${tutorial.build.dir}" />
<!-- Project dependencies - multi-project.html -->
<!-- Project dependencies - multi-project.html -->
<run-tutorial antfile="${tutorial.src.dir}/dependence/dependee/build.xml" target="publish" output="${output.dir}/dependence-standalone.txt" />
<run-tutorial antfile="${tutorial.src.dir}/dependence/depender/build.xml" output="${output.dir}/dependence-depending.txt" />
<run-tutorial antfile="${tutorial.src.dir}/dependence/dependee/build.xml" target="publish" output="${output.dir}/dependence-standalone-2.txt" />
<run-tutorial antfile="${tutorial.src.dir}/dependence/depender/build.xml" output="${output.dir}/dependence-depending-2.txt" />
<delete dir="${tutorial.build.dir}" />
<!-- configuration - Using Ivy Configuration - conf.html -->
<!-- configuration - Using Ivy Configuration - conf.html -->
<run-tutorial antfile="${tutorial.src.dir}/configurations/multi-projects/filter-framework/build.xml" output="${output.dir}/configurations-lib.txt" />
<run-tutorial antfile="${tutorial.src.dir}/configurations/multi-projects/myapp/build.xml" output="${output.dir}/configurations-runcc.txt" />
<run-tutorial antfile="${tutorial.src.dir}/configurations/multi-projects/myapp/build.xml" target="run-hm" output="${output.dir}/configurations-runhm.txt" />
<delete dir="${tutorial.build.dir}" />
<!--Building a repository - basic.html -->
<!--Building a repository - basic.html -->
<run-tutorial antfile="${tutorial.src.dir}/build-a-ivy-repository/build.xml" target="maven2" output="${output.dir}/install.txt" />
<pathconvert property="myrepository.content" pathsep="${line.separator}">
<fileset dir="${tutorial.src.dir}/build-a-ivy-repository/myrepository/no-namespace" />
@ -128,26 +128,26 @@
<echo file="${output.dir}/myrepository-content-deps.txt" append="true">${myrepository.content.deps}</echo>
<delete dir="${tutorial.build.dir}" />
<!--Building a repository - advanced.html -->
<!--Building a repository - advanced.html -->
<run-tutorial antfile="${tutorial.src.dir}/build-a-ivy-repository/build.xml" target="maven2-namespace" output="${output.dir}/install-namespace.txt" />
<pathconvert property="myrepository.content.namespace" pathsep="${line.separator}">
<fileset dir="${tutorial.src.dir}/build-a-ivy-repository/myrepository/advanced" />
</pathconvert>
<echo file="${output.dir}/myrepository-content-namespace.txt">$ find ${tutorial.src.dir}/build-a-ivy-repository/myrepository/advanced -type f -print${line.separator}</echo>
<echo file="${output.dir}/myrepository-content-namespace.txt">$ find ${tutorial.src.dir}/build-a-ivy-repository/myrepository/advanced -type f -print${line.separator}</echo>
<echo file="${output.dir}/myrepository-content-namespace.txt" append="true">${myrepository.content.namespace}</echo>
<delete dir="${tutorial.build.dir}" />
<!-- multi-project - multiproject.html -->
<!-- multi-project - multiproject.html -->
<run-tutorial antfile="${tutorial.src.dir}/multi-project/build.xml" target="-p" output="${output.dir}/multi-project-general-antp.txt" />
<run-tutorial antfile="${tutorial.src.dir}/multi-project/projects/find/build.xml" target="-p" output="${output.dir}/multi-project-find-antp.txt" />
<run-tutorial antfile="${tutorial.src.dir}/multi-project/build.xml" target="publish-all" output="${output.dir}/multi-project-general-publishall.txt" />
<delete dir="${tutorial.build.dir}" />
<!-- Correct the location of the examples to a dummy '/ivy' location -->
<pathconvert property="tutorial.root" dirsep="/">
<identitymapper/>
<path location="${tutorial.src.dir}"/>
</pathconvert>
<!-- Correct the location of the examples to a dummy '/ivy' location -->
<pathconvert property="tutorial.root" dirsep="/">
<identitymapper/>
<path location="${tutorial.src.dir}"/>
</pathconvert>
<pathconvert property="tutorial.local" dirsep="/">
<identitymapper/>
<path location="${tutorial.local-repo}"/>
@ -158,29 +158,22 @@
</pathconvert>
<replace dir="${output.dir}" token="\" value="/" />
<replace dir="${output.dir}" token="${tutorial.root}" value="/ivy" />
<replace dir="${output.dir}" token="${tutorial.root}" value="/ivy" />
<replace dir="${output.dir}" token="${tutorial.local}" value="/home/ivy/.ivy2/local" />
<replace dir="${output.dir}" token="${ivy.jar.location}" value="//home/ivy/ivy.jar" />
<replace dir="${output.dir}" token="-f build.xml " value="" />
<replace dir="${output.dir}" token="${ivy.revision}" value="working@apache" />
</target>
<replace dir="${output.dir}" token="-f build.xml " value="" />
<replace dir="${output.dir}" token="${ivy.revision}" value="working@apache" />
</target>
<target name="generate-doc" depends="init-ivy">
<ivy:cachepath pathid="asciidoctor.path">
<dependency org="org.asciidoctor" name="asciidoctor-ant" rev="1.5.4" />
<dependency org="org.asciidoctor" name="asciidoctor-ant" rev="1.5.4" />
</ivy:cachepath>
<taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml" classpathref="asciidoctor.path" />
<asciidoctor:convert sourceDirectory="${doc.src.dir}" outputDirectory="${doc.build.dir}" backend="xhtml5" templateDir="${doc.src.dir}/templates" preserveDirectories="true">
<attribute key="basedir" value="${doc.src.dir}" />
<attribute key="imagesdir" value="" />
</asciidoctor:convert>
<!-- the basedir seems to fuck up the path to the output directory, let's fix that manually >
<delete dir="${doc.build.dir}" />
<mkdir dir="${doc.build.dir}" />
<copy todir="${doc.build.dir}">
<fileset dir="${doc.src.dir}/${doc.build.dir}" />
</copy-->
<!-- copy static resources -->
<copy todir="${doc.build.dir}">
<fileset dir="${doc.src.dir}" includes="images/**,style/**,samples/**,js/**,ivy.xsd" />
@ -188,165 +181,165 @@
</copy>
</target>
<target name="all-doc" depends="javadoc, generate-doc" />
<target name="init-snapshot" depends="default-version">
<property name="snapshot.full.name" value="apache-ivy-${build.version}" />
</target>
<target name="all-doc" depends="javadoc, generate-doc" />
<target name="snapshot-metadata" depends="init-snapshot, resolve">
<mkdir dir="${artifacts.build.dir}"/>
<ivy:deliver
deliverpattern="${artifacts.build.dir}/ivy.xml"
pubrevision="${build.version}"
pubdate="${pubdate}"
status="${status}"/>
</target>
<target name="snapshot-src" depends="init-snapshot">
<delete dir="${build.dir}/snapshot-src" failonerror="false" />
<exec executable="git" failonerror="true">
<arg line="clone ${basedir} ${build.dir}/snapshot-src" />
</exec>
<exec dir="${build.dir}/snapshot-src" executable="git" failonerror="true">
<arg line="clean -d -x -f" />
</exec>
<mkdir dir="${distrib.dir}/dist/${build.version}"/>
<zip destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-src.zip">
<zipfileset dir="${build.dir}/snapshot-src" prefix="${snapshot.full.name}" />
</zip>
<tar destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-src.tar.gz"
compression="gzip" longfile="gnu">
<zipfileset src="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-src.zip"/>
</tar>
</target>
<target name="snapshot-bin-without-dependencies" depends="snapshot-metadata, jar, all-doc">
<mkdir dir="${distrib.dir}/dist/${build.version}"/>
<zip destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin.zip">
<zipfileset dir="${doc.build.dir}" prefix="${snapshot.full.name}/doc" excludes="**/reports/coverage/**,**/reports/test/**"/>
<zipfileset dir="${basedir}/src/example" prefix="${snapshot.full.name}/src/example"/>
<zipfileset dir="${basedir}" includes="NOTICE" fullpath="${snapshot.full.name}/NOTICE"/>
<zipfileset dir="${basedir}" includes="README" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="LICENSE*" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="CHANGES.txt" fullpath="${snapshot.full.name}/CHANGES.txt"/>
<zipfileset dir="${basedir}" includes="RELEASE_NOTES" fullpath="${snapshot.full.name}/RELEASE_NOTES"/>
<zipfileset dir="${src.dir}/org/apache/ivy/plugins/parser/xml" includes="ivy.xsd" fullpath="${snapshot.full.name}/ivy.xsd"/>
<zipfileset dir="${artifacts.build.dir}" includes="ivy.xml" fullpath="${snapshot.full.name}/ivy.xml"/>
<zipfileset dir="${basedir}" includes="build-for-bin-distrib.xml" fullpath="${snapshot.full.name}/build.xml"/>
<target name="init-snapshot" depends="default-version">
<property name="snapshot.full.name" value="apache-ivy-${build.version}" />
</target>
<zipfileset dir="${artifacts.build.dir}/jars" includes="${final.name}" fullpath="${snapshot.full.name}/ivy-${build.version}.jar"/>
</zip>
<tar destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin.tar.gz"
compression="gzip" longfile="gnu">
<zipfileset src="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin.zip"/>
</tar>
</target>
<target name="snapshot-metadata" depends="init-snapshot, resolve">
<mkdir dir="${artifacts.build.dir}"/>
<ivy:deliver
deliverpattern="${artifacts.build.dir}/ivy.xml"
pubrevision="${build.version}"
pubdate="${pubdate}"
status="${status}"/>
</target>
<target name="snapshot-bin-with-dependencies" depends="snapshot-metadata, jar, all-doc">
<mkdir dir="${distrib.dir}/dist/${build.version}"/>
<delete dir="${build.dir}/lib" />
<ivy:retrieve conf="default" pattern="${build.dir}/lib/[artifact]-[revision].[ext]" />
<zip destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin-with-deps.zip">
<zipfileset dir="${doc.build.dir}" prefix="${snapshot.full.name}/doc" excludes="**/reports/coverage/**,**/reports/test/**"/>
<zipfileset dir="${basedir}/src/example" prefix="${snapshot.full.name}/src/example"/>
<zipfileset dir="${basedir}" includes="NOTICE" fullpath="${snapshot.full.name}/NOTICE"/>
<zipfileset dir="${basedir}" includes="README" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="LICENSE*" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="CHANGES.txt" fullpath="${snapshot.full.name}/CHANGES.txt"/>
<zipfileset dir="${basedir}" includes="RELEASE_NOTES" fullpath="${snapshot.full.name}/RELEASE_NOTES"/>
<zipfileset dir="${src.dir}/org/apache/ivy/plugins/parser/xml" includes="ivy.xsd" fullpath="${snapshot.full.name}/ivy.xsd"/>
<zipfileset dir="${artifacts.build.dir}" includes="ivy.xml" fullpath="${snapshot.full.name}/ivy.xml"/>
<zipfileset dir="${artifacts.build.dir}/jars" includes="${final.name}" fullpath="${snapshot.full.name}/ivy-${build.version}.jar"/>
<target name="snapshot-src" depends="init-snapshot">
<delete dir="${build.dir}/snapshot-src" failonerror="false" />
<exec executable="git" failonerror="true">
<arg line="clone ${basedir} ${build.dir}/snapshot-src" />
</exec>
<exec dir="${build.dir}/snapshot-src" executable="git" failonerror="true">
<arg line="clean -d -x -f" />
</exec>
<mkdir dir="${distrib.dir}/dist/${build.version}"/>
<zip destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-src.zip">
<zipfileset dir="${build.dir}/snapshot-src" prefix="${snapshot.full.name}" />
</zip>
<tar destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-src.tar.gz"
compression="gzip" longfile="gnu">
<zipfileset src="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-src.zip"/>
</tar>
</target>
<zipfileset dir="${build.dir}/lib" prefix="${snapshot.full.name}/lib" excludes="ant-*.jar,bcpg-*.jar,bcprov*.jar" />
</zip>
<tar destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin-with-deps.tar.gz"
compression="gzip" longfile="gnu">
<zipfileset src="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin-with-deps.zip"/>
</tar>
</target>
<target name="snapshot-bin-without-dependencies" depends="snapshot-metadata, jar, all-doc">
<mkdir dir="${distrib.dir}/dist/${build.version}"/>
<zip destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin.zip">
<zipfileset dir="${doc.build.dir}" prefix="${snapshot.full.name}/doc" excludes="**/reports/coverage/**,**/reports/test/**"/>
<zipfileset dir="${basedir}/src/example" prefix="${snapshot.full.name}/src/example"/>
<zipfileset dir="${basedir}" includes="NOTICE" fullpath="${snapshot.full.name}/NOTICE"/>
<zipfileset dir="${basedir}" includes="README" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="LICENSE*" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="CHANGES.txt" fullpath="${snapshot.full.name}/CHANGES.txt"/>
<zipfileset dir="${basedir}" includes="RELEASE_NOTES" fullpath="${snapshot.full.name}/RELEASE_NOTES"/>
<zipfileset dir="${src.dir}/org/apache/ivy/plugins/parser/xml" includes="ivy.xsd" fullpath="${snapshot.full.name}/ivy.xsd"/>
<zipfileset dir="${artifacts.build.dir}" includes="ivy.xml" fullpath="${snapshot.full.name}/ivy.xml"/>
<zipfileset dir="${basedir}" includes="build-for-bin-distrib.xml" fullpath="${snapshot.full.name}/build.xml"/>
<target name="snapshot-bin"
depends="snapshot-bin-with-dependencies, snapshot-bin-without-dependencies" />
<target name="release-xsd" depends="init-snapshot">
<!-- copies current ivy xml schema to doc source, so that it will be available from web site -->
<copy file="${src.dir}/org/apache/ivy/plugins/parser/xml/ivy.xsd" todir="${doc.src.dir}" />
</target>
<zipfileset dir="${artifacts.build.dir}/jars" includes="${final.name}" fullpath="${snapshot.full.name}/ivy-${build.version}.jar"/>
</zip>
<tar destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin.tar.gz"
compression="gzip" longfile="gnu">
<zipfileset src="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin.zip"/>
</tar>
</target>
<target name="snapshot-maven2" depends="init-snapshot, snapshot-metadata, jar, sources, javadoc">
<property name="m2.distrib.dir" value="${distrib.dir}/maven2/${build.version}" />
<ivy:makepom ivyfile="${artifacts.build.dir}/ivy.xml"
pomfile="${m2.distrib.dir}/ivy-${build.version}.pom"
templatefile="${basedir}/src/etc/makepom/pom.template">
<mapping conf="core" scope="compile"/>
<mapping conf="test" scope="test"/>
</ivy:makepom>
<copy file="${artifacts.build.dir}/jars/${final.name}"
tofile="${m2.distrib.dir}/ivy-${build.version}.jar" />
<!-- jar javadocs -->
<jar destfile="${m2.distrib.dir}/ivy-${build.version}-javadoc.jar">
<fileset dir="${javadoc.build.dir}" />
</jar>
<!-- copy sources jar -->
<copy file="${artifacts.build.dir}/sources/${final.name}"
tofile="${m2.distrib.dir}/ivy-${build.version}-sources.jar" />
<target name="snapshot-bin-with-dependencies" depends="snapshot-metadata, jar, all-doc">
<mkdir dir="${distrib.dir}/dist/${build.version}"/>
<delete dir="${build.dir}/lib" />
<ivy:retrieve conf="default" pattern="${build.dir}/lib/[artifact]-[revision].[ext]" />
<zip destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin-with-deps.zip">
<zipfileset dir="${doc.build.dir}" prefix="${snapshot.full.name}/doc" excludes="**/reports/coverage/**,**/reports/test/**"/>
<zipfileset dir="${basedir}/src/example" prefix="${snapshot.full.name}/src/example"/>
<zipfileset dir="${basedir}" includes="NOTICE" fullpath="${snapshot.full.name}/NOTICE"/>
<zipfileset dir="${basedir}" includes="README" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="LICENSE*" prefix="${snapshot.full.name}"/>
<zipfileset dir="${basedir}" includes="CHANGES.txt" fullpath="${snapshot.full.name}/CHANGES.txt"/>
<zipfileset dir="${basedir}" includes="RELEASE_NOTES" fullpath="${snapshot.full.name}/RELEASE_NOTES"/>
<zipfileset dir="${src.dir}/org/apache/ivy/plugins/parser/xml" includes="ivy.xsd" fullpath="${snapshot.full.name}/ivy.xsd"/>
<zipfileset dir="${artifacts.build.dir}" includes="ivy.xml" fullpath="${snapshot.full.name}/ivy.xml"/>
<checksum algorithm="md5">
<fileset dir="${m2.distrib.dir}">
<include name="*.pom"/>
<include name="*.jar"/>
</fileset>
</checksum>
<checksum algorithm="sha1">
<fileset dir="${m2.distrib.dir}">
<include name="*.pom"/>
<include name="*.jar"/>
</fileset>
</checksum>
</target>
<zipfileset dir="${artifacts.build.dir}/jars" includes="${final.name}" fullpath="${snapshot.full.name}/ivy-${build.version}.jar"/>
<target name="snapshot-checksums">
<checksum algorithm="md5">
<fileset dir="${distrib.dir}/dist/${build.version}">
<include name="*.pom"/>
<include name="*.jar"/>
<include name="*.zip"/>
<include name="*.gz"/>
</fileset>
</checksum>
<checksum algorithm="sha">
<fileset dir="${distrib.dir}/dist/${build.version}">
<include name="*.pom"/>
<include name="*.jar"/>
<include name="*.zip"/>
<include name="*.gz"/>
</fileset>
</checksum>
</target>
<target name="snapshot-version">
<property name="version.prefix" value="${target.ivy.version}-dev-"/>
</target>
<target name="release-version">
<property name="build.version" value="${target.ivy.version}" />
<echo>Setting version to ${build.version}</echo>
<condition property="status" value="release">
<matches pattern="^\d+\.\d+\.\d+$" string="${build.version}"/>
</condition>
<condition property="status" value="milestone">
<matches pattern="^\d+\.\d+\.\d+-(alpha|beta|rc)\d+$" string="${build.version}"/>
</condition>
<property name="status" value="integration" />
<echo>Setting status to ${status}</echo>
</target>
<target name="sign" depends="init-ivy">
<zipfileset dir="${build.dir}/lib" prefix="${snapshot.full.name}/lib" excludes="ant-*.jar,bcpg-*.jar,bcprov*.jar" />
</zip>
<tar destfile="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin-with-deps.tar.gz"
compression="gzip" longfile="gnu">
<zipfileset src="${distrib.dir}/dist/${build.version}/${snapshot.full.name}-bin-with-deps.zip"/>
</tar>
</target>
<target name="snapshot-bin"
depends="snapshot-bin-with-dependencies, snapshot-bin-without-dependencies" />
<target name="release-xsd" depends="init-snapshot">
<!-- copies current ivy xml schema to doc source, so that it will be available from web site -->
<copy file="${src.dir}/org/apache/ivy/plugins/parser/xml/ivy.xsd" todir="${doc.src.dir}" />
</target>
<target name="snapshot-maven2" depends="init-snapshot, snapshot-metadata, jar, sources, javadoc">
<property name="m2.distrib.dir" value="${distrib.dir}/maven2/${build.version}" />
<ivy:makepom ivyfile="${artifacts.build.dir}/ivy.xml"
pomfile="${m2.distrib.dir}/ivy-${build.version}.pom"
templatefile="${basedir}/src/etc/makepom/pom.template">
<mapping conf="core" scope="compile"/>
<mapping conf="test" scope="test"/>
</ivy:makepom>
<copy file="${artifacts.build.dir}/jars/${final.name}"
tofile="${m2.distrib.dir}/ivy-${build.version}.jar" />
<!-- jar javadocs -->
<jar destfile="${m2.distrib.dir}/ivy-${build.version}-javadoc.jar">
<fileset dir="${javadoc.build.dir}" />
</jar>
<!-- copy sources jar -->
<copy file="${artifacts.build.dir}/sources/${final.name}"
tofile="${m2.distrib.dir}/ivy-${build.version}-sources.jar" />
<checksum algorithm="md5">
<fileset dir="${m2.distrib.dir}">
<include name="*.pom"/>
<include name="*.jar"/>
</fileset>
</checksum>
<checksum algorithm="sha1">
<fileset dir="${m2.distrib.dir}">
<include name="*.pom"/>
<include name="*.jar"/>
</fileset>
</checksum>
</target>
<target name="snapshot-checksums">
<checksum algorithm="md5">
<fileset dir="${distrib.dir}/dist/${build.version}">
<include name="*.pom"/>
<include name="*.jar"/>
<include name="*.zip"/>
<include name="*.gz"/>
</fileset>
</checksum>
<checksum algorithm="sha">
<fileset dir="${distrib.dir}/dist/${build.version}">
<include name="*.pom"/>
<include name="*.jar"/>
<include name="*.zip"/>
<include name="*.gz"/>
</fileset>
</checksum>
</target>
<target name="snapshot-version">
<property name="version.prefix" value="${target.ivy.version}-dev-"/>
</target>
<target name="release-version">
<property name="build.version" value="${target.ivy.version}" />
<echo>Setting version to ${build.version}</echo>
<condition property="status" value="release">
<matches pattern="^\d+\.\d+\.\d+$" string="${build.version}"/>
</condition>
<condition property="status" value="milestone">
<matches pattern="^\d+\.\d+\.\d+-(alpha|beta|rc)\d+$" string="${build.version}"/>
</condition>
<property name="status" value="integration" />
<echo>Setting status to ${status}</echo>
</target>
<target name="sign" depends="init-ivy">
<property file="${user.home}/ivybuild.properties" />
<input message="please enter your PGP password: " addproperty="pgp.password"/>
<input message="please enter your PGP keyId: " addproperty="pgp.keyId"/>
@ -368,54 +361,54 @@
module="bcprov-jdk16" revision="1.45" inline="true" pathid="bouncycastle.bcprov.classpath"/>
<ivy2:cachepath organisation="org.bouncycastle" settingsRef="sign.settingsId" transitive="false" log="download-only"
module="bcpg-jdk16" revision="1.45" inline="true" pathid="bouncycastle.bcpg.classpath"/>
<!--
For some reason, if we use the openpgp:signer task here directly, the bouncycastle security
provider cannot be loaded. If we launch it as a forked process everything works fine !?!
-->
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true">
<classpath>
<fileset dir="${ant.home}" includes="**/*.jar" />
<path refid="bouncycastle.bcprov.classpath" />
<path refid="bouncycastle.bcpg.classpath" />
<path refid="openpgp.classpath" />
</classpath>
<arg line="-f build-release.xml" />
<arg line="sign-internal" />
<arg line="-Dpgp.password=${pgp.password}" />
<arg line="-Dpgp.keyId=${pgp.keyId}" />
</java>
</target>
<target name="sign-internal">
<property file="build.properties" />
<taskdef resource="org/apache/commons/openpgp/ant/antlib.xml" uri="antlib:org.apache.commons.openpgp.ant" />
<openpgp:signer secring="${user.home}/.gnupg/secring.gpg"
pubring="${user.home}/.gnupg/pubring.gpg"
password="${pgp.password}"
keyid="${pgp.keyId}"
asciiarmor="true">
<fileset dir="${distrib.dir}">
<include name="**/*.pom"/>
<include name="**/*.jar"/>
<include name="**/*.zip"/>
<include name="**/*.gz"/>
</fileset>
</openpgp:signer>
</target>
<target name="rat" depends="init-ivy">
<property name="rat.failOnError" value="true"/>
<ivy:cachepath organisation="org.apache.rat" module="apache-rat-tasks" revision="0.6"
inline="true" conf="default" pathid="rat.classpath"
log="download-only"/>
<typedef resource="org/apache/rat/anttasks/antlib.xml"
uri="antlib:org.apache.rat.anttasks"
classpathref="rat.classpath" />
<delete dir="${rat.report.dir}"/>
<!--
For some reason, if we use the openpgp:signer task here directly, the bouncycastle security
provider cannot be loaded. If we launch it as a forked process everything works fine !?!
-->
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true">
<classpath>
<fileset dir="${ant.home}" includes="**/*.jar" />
<path refid="bouncycastle.bcprov.classpath" />
<path refid="bouncycastle.bcpg.classpath" />
<path refid="openpgp.classpath" />
</classpath>
<arg line="-f build-release.xml" />
<arg line="sign-internal" />
<arg line="-Dpgp.password=${pgp.password}" />
<arg line="-Dpgp.keyId=${pgp.keyId}" />
</java>
</target>
<target name="sign-internal">
<property file="build.properties" />
<taskdef resource="org/apache/commons/openpgp/ant/antlib.xml" uri="antlib:org.apache.commons.openpgp.ant" />
<openpgp:signer secring="${user.home}/.gnupg/secring.gpg"
pubring="${user.home}/.gnupg/pubring.gpg"
password="${pgp.password}"
keyid="${pgp.keyId}"
asciiarmor="true">
<fileset dir="${distrib.dir}">
<include name="**/*.pom"/>
<include name="**/*.jar"/>
<include name="**/*.zip"/>
<include name="**/*.gz"/>
</fileset>
</openpgp:signer>
</target>
<target name="rat" depends="init-ivy">
<property name="rat.failOnError" value="true"/>
<ivy:cachepath organisation="org.apache.rat" module="apache-rat-tasks" revision="0.6"
inline="true" conf="default" pathid="rat.classpath"
log="download-only"/>
<typedef resource="org/apache/rat/anttasks/antlib.xml"
uri="antlib:org.apache.rat.anttasks"
classpathref="rat.classpath" />
<delete dir="${rat.report.dir}"/>
<mkdir dir="${rat.report.dir}"/>
<rat:report xmlns:rat="antlib:org.apache.rat.anttasks" reportFile="${rat.report.dir}/rat-report.txt">
<fileset dir="${basedir}">
@ -443,8 +436,8 @@
</and>
</condition>
</fail>
</target>
</target>
<target name="upload-nexus" depends="release-version, init-ivy, jar">
<ivy:retrieve conf="default" pattern="${build.dir}/lib/[artifact]-[revision].[ext]" />
@ -455,7 +448,7 @@
<fileset dir="${build.dir}/lib" excludes="ant-*.jar" />
</classpath>
</taskdef>
<property file="${user.home}/ivybuild.properties" />
<input message="please enter your PGP password: " addproperty="pgp.password"/>
<input message="please enter your PGP keyId: " addproperty="pgp.keyId"/>
@ -481,11 +474,11 @@
</ivy2:publish>
</target>
<target name="prepare-snapshot"
depends="/localivy, clean-ivy-home, clean, clean-lib, snapshot-version, install, clean-examples, coverage-report" />
<target name="snapshot"
depends="prepare-snapshot, snapshot-src, snapshot-bin, snapshot-maven2, snapshot-checksums"
description="used for nightly and integration builds"/>
<target name="release" depends="release-version, /localivy, clean-ivy-home, clean, clean-lib, rat, snapshot" description="make a new release of Ivy"/>
<target name="prepare-snapshot"
depends="/localivy, clean-ivy-home, clean, clean-lib, snapshot-version, install, clean-examples, coverage-report" />
<target name="snapshot"
depends="prepare-snapshot, snapshot-src, snapshot-bin, snapshot-maven2, snapshot-checksums"
description="used for nightly and integration builds"/>
<target name="release" depends="release-version, /localivy, clean-ivy-home, clean, clean-lib, rat, snapshot" description="make a new release of Ivy"/>
</project>

287
build.xml
View File

@ -14,27 +14,27 @@
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
under the License.
-->
<project name="ivy" default="coverage-report" xmlns:ivy="antlib:org.apache.ivy.ant">
<property environment="env" />
<property environment="env" />
<property file="version.properties" />
<property file="build.properties" />
<property name="final.name" value="ivy.jar" />
<target name="init-ivy-user-home" unless="ivy.use.local.home">
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ivy2" />
</target>
<target name="init-ivy-local-home" if="ivy.use.local.home">
<property name="ivy.home" value="${basedir}/.ivy2" />
</target>
<target name="init-ivy-home" depends="init-ivy-user-home, init-ivy-local-home" />
<target name="init-ivy" depends="compile-bootstrap, init-ivy-home">
@ -45,18 +45,18 @@
<pathelement location="${bootstrap.classes.build.dir}" />
</classpath>
</taskdef>
<ivy:configure override="true" />
</target>
<target name="install" depends="init-ivy-home, jar"
description="build Ivy and install it in Ivy user home for builds using Ivy user home to load Ivy jar">
<target name="install" depends="init-ivy-home, jar"
description="build Ivy and install it in Ivy user home for builds using Ivy user home to load Ivy jar">
<property name="ivy.jar.file" value="${ivy.home}/jars/ivy.jar" />
<copy file="${artifacts.build.dir}/jars/${final.name}" tofile="${ivy.jar.file}" />
</target>
<target name="install-ant" depends="init-ivy-home, jar"
description="build Ivy and install it in Ant home lib">
description="build Ivy and install it in Ant home lib">
<condition property="ant.home" value="${env.ANT_HOME}">
<isset property="env.ANT_HOME" />
</condition>
@ -95,8 +95,8 @@
<include name="*.jar" />
<exclude name="ant.jar" />
<exclude name="ant-launcher.jar" />
<exclude name="ant-nodeps.jar"/>
<exclude name="ant-trax.jar"/>
<exclude name="ant-nodeps.jar"/>
<exclude name="ant-trax.jar"/>
</fileset>
<pathelement location="${core.classes.build.dir}" />
<pathelement location="${ant.classes.build.dir}" />
@ -104,20 +104,20 @@
<pathelement path="${test.build.dir}" />
</path>
</target>
<target name="prepare" depends="init">
<mkdir dir="${classes.build.dir}" />
<mkdir dir="${core.classes.build.dir}" />
<mkdir dir="${bootstrap.classes.build.dir}" />
<mkdir dir="${bootstrap.classes.build.dir}" />
<mkdir dir="${ant.classes.build.dir}" />
<mkdir dir="${optional.classes.build.dir}" />
<mkdir dir="${all.classes.build.dir}" />
<mkdir dir="${test.build.dir}" />
<mkdir dir="${artifacts.build.dir}" />
<mkdir dir="${test.report.dir}" />
<mkdir dir="${ivy.report.dir}" />
<mkdir dir="${ivy.report.dir}" />
</target>
<target name="clean" description="delete all generated files keeping sources only">
<delete dir="${classes.build.dir}" />
<delete dir="${test.build.dir}" />
@ -127,49 +127,49 @@
<delete dir="${doc.build.dir}" />
<delete dir="${build.dir}" />
</target>
<target name="clean-lib">
<delete dir="${lib.dir}" />
</target>
<target name="clean-ivy-cache" depends="init-ivy-home">
<delete dir="${ivy.home}/cache" />
</target>
<target name="clean-ivy-home" depends="init-ivy-home">
<delete dir="${ivy.home}" />
</target>
<target name="clean-examples" description="clean all examples">
<subant target="clean" failonerror="false">
<fileset dir="${example.dir}" includes="**/build.xml" />
</subant>
</subant>
</target>
<target name="clean-all" depends="clean, clean-lib, clean-examples" />
<target name="/noresolve" description="use to skip dependency resolution">
<property name="no.resolve" value="true" />
</target>
<target name="/notest" description="use to skip tests">
<property name="skip.test" value="true" />
</target>
<target name="/nojavadoc" description="use to skip javadoc">
<property name="skip.javadoc" value="true" />
</target>
<target name="/localivy" description="use a local ivy home">
<property name="ivy.use.local.home" value="true" />
</target>
<target name="/offline" depends="/noresolve" description="use to indicate no internet connection is available">
<property name="offline" value="true" />
</target>
<target name="default-version">
<tstamp>
<tstamp>
<format property="pubdate" pattern="yyyyMMddHHmmss" />
</tstamp>
<property name="version.prefix" value="${target.ivy.version}-local-" />
@ -187,7 +187,7 @@
<target name="compile-core" depends="prepare">
<javac srcdir="${src.dir}"
destdir="${core.classes.build.dir}"
sourcepath=""
sourcepath=""
source="${ivy.minimum.javaversion}"
target="${ivy.minimum.javaversion}"
debug="${debug.mode}"
@ -202,7 +202,7 @@
<excludesfile name="optional.patterns" />
</fileset>
</copy>
<!-- copy settings files for backward compatibility with ivyconf naming -->
<copy file="${core.classes.build.dir}/org/apache/ivy/core/settings/ivysettings-local.xml"
tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf-local.xml" />
@ -218,11 +218,11 @@
tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf.xml" />
</target>
<!-- Build the Ant tasks with the current Ant runtime -->
<!-- Build the Ant tasks with the current Ant runtime -->
<target name="compile-bootstrap" depends="compile-core">
<javac srcdir="${src.dir}"
destdir="${bootstrap.classes.build.dir}"
sourcepath=""
sourcepath=""
classpathref="build.bootstrap.classpath"
source="${ivy.minimum.javaversion}"
target="${ivy.minimum.javaversion}"
@ -237,12 +237,12 @@
</fileset>
</copy>
</target>
<!-- Build the Ant tasks with the minimal Ant runtime -->
<!-- Build the Ant tasks with the minimal Ant runtime -->
<target name="compile-ant" depends="compile-core, resolve">
<javac srcdir="${src.dir}"
destdir="${ant.classes.build.dir}"
sourcepath=""
sourcepath=""
classpathref="build.ant.classpath"
source="${ivy.minimum.javaversion}"
target="${ivy.minimum.javaversion}"
@ -256,16 +256,16 @@
<exclude name="**/*.java" />
</fileset>
</copy>
<!-- copy antlib for backward compatibility with fr.jayasoft.ivy package -->
<copy file="${ant.classes.build.dir}/org/apache/ivy/ant/antlib.xml"
<copy file="${ant.classes.build.dir}/org/apache/ivy/ant/antlib.xml"
todir="${ant.classes.build.dir}/fr/jayasoft/ivy/ant" />
</target>
<target name="compile-optional" depends="compile-ant, resolve">
<javac srcdir="${src.dir}"
destdir="${optional.classes.build.dir}"
sourcepath=""
sourcepath=""
classpathref="build.optional.classpath"
source="${ivy.minimum.javaversion}"
target="${ivy.minimum.javaversion}"
@ -290,18 +290,18 @@
<echo message="version=${build.version}${line.separator}" file="${core.classes.build.dir}/module.properties" append="true" />
<echo message="date=${pubdate}${line.separator}" file="${core.classes.build.dir}/module.properties" append="true" />
<mkdir dir="${artifacts.build.dir}/jars/"/>
<!--
there is a default Bundle-Version attribute in the source MANIFEST, used to ease
development in eclipse.
We remove this line to make sure we get the Bundle-Version as set in the jar task
-->
<copy file="${basedir}/META-INF/MANIFEST.MF" tofile="${artifacts.build.dir}/MANIFEST.MF">
<filterchain>
<replaceregex pattern="Bundle-Version:.*" replace="Bundle-Version: ${bundle.version}" byline="true" />
</filterchain>
</copy>
<mkdir dir="${artifacts.build.dir}/jars/"/>
<!--
there is a default Bundle-Version attribute in the source MANIFEST, used to ease
development in eclipse.
We remove this line to make sure we get the Bundle-Version as set in the jar task
-->
<copy file="${basedir}/META-INF/MANIFEST.MF" tofile="${artifacts.build.dir}/MANIFEST.MF">
<filterchain>
<replaceregex pattern="Bundle-Version:.*" replace="Bundle-Version: ${bundle.version}" byline="true" />
</filterchain>
</copy>
<copy todir="${all.classes.build.dir}">
<fileset dir="${core.classes.build.dir}" />
@ -325,24 +325,24 @@
</manifest>
<fileset dir="${all.classes.build.dir}" />
</jar>
<!-- copy main jar to ease its use as an OSGi bundle -->
<copy file="${artifacts.build.dir}/jars/${final.name}"
tofile="${artifacts.build.dir}/org.apache.ivy_${bundle.version}.jar" />
<!-- copy main jar to ease its use as an OSGi bundle -->
<copy file="${artifacts.build.dir}/jars/${final.name}"
tofile="${artifacts.build.dir}/org.apache.ivy_${bundle.version}.jar" />
<!-- clean generated module properties file -->
<delete file="${core.classes.build.dir}/module.properties" />
</target>
<!-- =================================================================
<!-- =================================================================
PUBLISH LOCAL
================================================================= -->
<target name="publish-local" depends="jar,sources" description="publishes Ivy to Ivy local repository">
<ivy:publish resolver="local" pubrevision="${build.version}"
artifactsPattern="${artifacts.build.dir}/[type]s/[artifact].[ext]"
artifactsPattern="${artifacts.build.dir}/[type]s/[artifact].[ext]"
forcedeliver="true" />
</target>
<!-- =================================================================
<!-- =================================================================
TESTS
================================================================= -->
<target name="build-custom-resolver-jar" depends="jar">
@ -365,23 +365,23 @@
<not><contains text="remote.test" /></not>
</fileset>
</target>
<target name="init-tests-online" unless="offline">
<fileset id="test.fileset" dir="${test.dir}">
<include name="**/${test.class.pattern}.java" />
<exclude name="**/Abstract*Test.java" />
</fileset>
</target>
<target name="init-tests" depends="init-tests-offline, init-tests-online" />
<target name="emma" depends="jar" unless="skip.test">
<ivy:cachepath organisation="emma" module="emma" revision="2.0.5312"
inline="true" conf="default" pathid="emma.classpath"
log="download-only" />
<ivy:cachepath organisation="emma" module="emma_ant" revision="2.0.5312"
inline="true" conf="default" pathid="emma.ant.classpath" transitive="false"
log="download-only" />
<ivy:cachepath organisation="emma" module="emma" revision="2.0.5312"
inline="true" conf="default" pathid="emma.classpath"
log="download-only" />
<ivy:cachepath organisation="emma" module="emma_ant" revision="2.0.5312"
inline="true" conf="default" pathid="emma.ant.classpath" transitive="false"
log="download-only" />
<taskdef resource="emma_ant.properties">
<classpath refid="emma.classpath" />
<classpath refid="emma.ant.classpath" />
@ -403,14 +403,14 @@
</instr>
</emma>
<delete file="${coverage.dir}/coverage.emma" />
<!-- add emma path to test path, because emma jars need to be available when running
<!-- add emma path to test path, because emma jars need to be available when running
instrumented classes -->
<ivy:addpath topath="test.classpath" first="true">
<pathelement location="${coverage.dir}/classes" />
<path refid="emma.classpath" />
</ivy:addpath>
</target>
<target name="build-test" depends="jar">
<javac srcdir="${test.dir}"
destdir="${test.build.dir}"
@ -427,12 +427,12 @@
</copy>
</target>
<target name="prepare-osgi-tests" depends="resolve" unless="skip.test">
<target name="prepare-osgi-tests" depends="resolve" unless="skip.test">
<ant dir="${basedir}/test/test-repo" target="generate-bundles" />
</target>
</target>
<target name="prepare-test-jar-repositories" unless="skip.test">
<mkdir dir="${basedir}/test/jar-repos" />
<mkdir dir="${basedir}/test/jar-repos" />
<jar destfile="${basedir}/test/jar-repos/jarrepo1.jar" >
<fileset dir="${basedir}/test/repositories/1" />
</jar>
@ -441,10 +441,10 @@
</jar>
</target>
<target name="test-internal" depends="build-test, init-tests, prepare-osgi-tests, prepare-test-jar-repositories" unless="skip.test">
<target name="test-internal" depends="build-test, init-tests, prepare-osgi-tests, prepare-test-jar-repositories" unless="skip.test">
<mkdir dir="${test.xml.dir}" />
<junit
<junit
haltonfailure="off"
haltonerror="off"
errorproperty="test.failed"
@ -459,30 +459,40 @@
<pathelement path="${ant.home}/lib/ant-nodeps.jar"/>
<pathelement path="${ant.home}/lib/ant-trax.jar"/>
</classpath>
<!-- pass the proxy properties to the forked junit process to use correct proxy -->
<syspropertyset>
<propertyref prefix="http" />
</syspropertyset>
<!-- pass the proxy properties to the forked junit process to use correct proxy -->
<syspropertyset>
<propertyref prefix="http" />
</syspropertyset>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<!-- Added this to test IVY-65 -->
<jvmarg value="-Duser.region=TR" />
<jvmarg value="-Duser.language=tr" />
<formatter type="xml"/>
<batchtest todir="${test.xml.dir}">
<fileset refid="test.fileset" />
</batchtest>
</junit>
</target>
<target name="x" depends="init,build-test">
<java classname="org.apache.ivy.plugins.resolver.FileSystemResolverTest">
<classpath>
<path refid="test.classpath" />
<pathelement path="${ant.home}/lib/ant-nodeps.jar"/>
<pathelement path="${ant.home}/lib/ant-trax.jar"/>
</classpath>
</java>
</target>
<target name="test" depends="test-internal" description="Run the test">
<fail if="test.failed"
message="At least one test has failed. See logs (in ${test.xml.dir}) for details (use the target test-report to run the test with a report)" />
</target>
<!-- =================================================================
REPORTS AND DOCUMENTATION
================================================================= -->
@ -496,7 +506,7 @@
<fail if="test.failed"
message="At least one test has failed. See logs (in ${test.xml.dir}) or report (in ${test.report.dir})" />
</target>
<target name="coverage-report" depends="emma, test-report" unless="skip.test"
description="run tests with instrumentation and generate coverage report">
<mkdir dir="${coverage.report.dir}" />
@ -511,19 +521,19 @@
</report>
</emma>
</target>
<target name="ivy-report" depends="resolve">
<ivy:report todir="${ivy.report.dir}"/>
</target>
<target name="ivy-report" depends="resolve">
<ivy:report todir="${ivy.report.dir}"/>
</target>
<target name="javadoc" unless="skip.javadoc">
<javadoc destdir="${javadoc.build.dir}" useexternalfile="true">
<fileset dir="${src.dir}" includes="**/*.java" />
</javadoc>
</target>
<target name="sources" depends="default-version" description="Create source archive files">
<mkdir dir="${artifacts.build.dir}/sources/"/>
<mkdir dir="${artifacts.build.dir}/sources/"/>
<jar destfile="${artifacts.build.dir}/sources/${final.name}">
<metainf dir="${basedir}" includes="LICENSE,NOTICE" />
<manifest>
@ -533,21 +543,21 @@
</manifest>
<fileset dir="${src.dir}" />
</jar>
</target>
</target>
<target name="fixcrlf">
<property name="eol.native.includes"
<property name="eol.native.includes"
value="**/*.html,**/*.json,**/*.java,**/*.xml,**/*.txt,**/*.MF,**/*.properties,**/*.patterns,**/*.pom,**/*.xsl,**/*.css" />
<property name="eol.native.excludes"
<property name="eol.native.excludes"
value="build/**,bin/**,lib/**" />
<fileset id="eol.native.fileset"
dir="${basedir}"
<fileset id="eol.native.fileset"
dir="${basedir}"
includes="${eol.native.includes}"
excludes="${eol.native.excludes}" />
<fixcrlf srcdir="${basedir}"
includes="${eol.native.includes}"
<fixcrlf srcdir="${basedir}"
includes="${eol.native.includes}"
excludes="${eol.native.excludes}" />
<apply executable="svn">
<fileset refid="eol.native.fileset" />
@ -556,20 +566,20 @@
<arg value='"native"' />
</apply>
</target>
<!-- Checks Ivy codebase according to ${checkstyle.src.dir}/checkstyle-config -->
<target name="checkstyle-internal" depends="jar">
<ivy:cachepath organisation="checkstyle" module="checkstyle" revision="5.0"
inline="true" conf="default" pathid="checkstyle.classpath" transitive="true"
log="download-only"/>
inline="true" conf="default" pathid="checkstyle.classpath" transitive="true"
log="download-only"/>
<taskdef resource="checkstyletask.properties" classpathref="checkstyle.classpath" />
<mkdir dir="${checkstyle.report.dir}" />
<checkstyle config="${checkstyle.src.dir}/checkstyle-config"
failOnViolation="false" failureProperty="checkstyle.failed">
<classpath>
<path refid="run.classpath" />
</classpath>
<checkstyle config="${checkstyle.src.dir}/checkstyle-config"
failOnViolation="false" failureProperty="checkstyle.failed">
<classpath>
<path refid="run.classpath" />
</classpath>
<formatter type="xml" toFile="${checkstyle.report.dir}/checkstyle.xml" />
<fileset dir="${src.dir}">
<include name="**/*.java" />
@ -578,11 +588,11 @@
<include name="**/*.java" />
</fileset>
</checkstyle>
</target>
</target>
<target name="checkstyle" depends="checkstyle-internal" description="checks Ivy codebase according to ${checkstyle.src.dir}/checkstyle-config">
<fail if="checkstyle.failed"
message="Checkstyle has errors. See report in ${checkstyle.report.dir}" />
<fail if="checkstyle.failed"
message="Checkstyle has errors. See report in ${checkstyle.report.dir}" />
</target>
<target name="checkstyle-report" depends="checkstyle-internal">
@ -596,37 +606,40 @@
<target name="init-findbugs" unless="findbugs.home">
<!-- Findbugs: Getting Findbugs -->
<property name="findbugs.download.name"
value="findbugs-1.3.5"
<property name="findbugs.version"
value="1.3.5"
description="Version of Findbugs to use"/>
<property name="findbugs.download.name"
value="findbugs-${findbugs.version}"
description="Name of the download file without suffix. Also the internal root directory of the ZIP."/>
<property name="findbugs.download.file"
<property name="findbugs.download.file"
value="${findbugs.download.name}.zip"
description="The filename of the ZIP."/>
<property name="findbugs.download.url"
value="http://garr.dl.sourceforge.net/sourceforge/findbugs/${findbugs.download.file}"
<property name="findbugs.download.url"
value="https://jaist.dl.sourceforge.net/project/findbugs/findbugs/${findbugs.version}/${findbugs.download.file}"
description="The download adress at a mirror of Sourceforge."/>
<property name="findbugs.download.to"
<property name="findbugs.download.to"
value="${build.dir}/.downloads"
description="Where to store the download and 'install' Findbugs."/>
<available
property="findbugs.home"
<available
property="findbugs.home"
value="${findbugs.download.to}/${findbugs.download.name}"
file="${findbugs.download.to}/${findbugs.download.name}/lib/findbugs.jar"
description="Check if Findbugs is already installed."
/>
<!-- Findbugs: Running Findbugs -->
<property name="findbugs.reportdir"
location="${reports.dir}/findbugs"
<property name="findbugs.reportdir"
location="${reports.dir}/findbugs"
description="Where to store Findbugs results"/>
<property name="findbugs.raw"
value="raw.xml"
<property name="findbugs.raw"
value="raw.xml"
description="Findbugs Output xml-file"/>
<property name="findbugs.xsl"
value="fancy.xsl"
<property name="findbugs.xsl"
value="fancy.xsl"
description="Which XSL to use for generating Output: default, fancy, plain, summary"/>
<property name="findbugs.jvmargs"
value="-Xms128m -Xmx512m"
<property name="findbugs.jvmargs"
value="-Xms128m -Xmx512m"
description="JVMArgs for invoking Findbugs"/>
<mkdir dir="${findbugs.download.to}"/>
@ -635,15 +648,15 @@
<property name="findbugs.home" location="${findbugs.download.to}/${findbugs.download.name}"/>
<mkdir dir="${findbugs.home}/plugin"/>
</target>
<target name="findbugs" description="checks Ivy codebase with Findbugs" depends="init-findbugs,compile-core" xmlns:fb="http://findbugs.sourceforge.net/">
<path id="findbugs.real.classpath">
<fileset dir="${findbugs.home}/lib" includes="*.jar"/>
</path>
<!-- Load the Findbugs AntTasks -->
<!-- Load the Findbugs AntTasks -->
<taskdef uri="http://findbugs.sourceforge.net/" resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpathref="findbugs.real.classpath" />
<!-- Start Findbugs -->
<mkdir dir="${findbugs.reportdir}"/>
<fb:findbugs home="${findbugs.home}"
@ -655,27 +668,27 @@
<class location="${core.classes.build.dir}" />
<sourcePath path="${src.dir}" />
</fb:findbugs>
<!-- Generate (human) readable output -->
<xslt basedir="${findbugs.reportdir}" includes="${findbugs.raw}" destdir="${findbugs.reportdir}">
<style>
<javaresource name="${findbugs.xsl}" classpathref="findbugs.real.classpath"/>
</style>
</style>
</xslt>
</target>
<!-- =================================================================
IDE SPECIFIC
================================================================= -->
<available file="${basedir}/.classpath" property="eclipse.classpath.exists" />
<target name="check-eclipse-classpath-overwrite" if="eclipse.classpath.exists">
<input message=".classpath file already exists.${line.separator}Are you sure you want to overwrite it and loose your original file?"
<input message=".classpath file already exists.${line.separator}Are you sure you want to overwrite it and loose your original file?"
validargs="Y,N,y,n" addproperty="eclipse.classpath.confirm" />
<condition property="eclipse.classpath.abort">
<equals arg1="${eclipse.classpath.confirm}" arg2="N" casesensitive="false" />
</condition>
</target>
<target name="eclipse-default" depends="resolve, check-eclipse-classpath-overwrite"
unless="eclipse.classpath.abort"
description="creates a default .classpath for eclipse, using jars resolved by this ant build">

View File

@ -34,13 +34,41 @@
<download-page rdf:resource="http://ant.apache.org/ivy/download.cgi" />
<programming-language>Java</programming-language>
<category rdf:resource="http://projects.apache.org/category/build-management" />
<release>
<Version>
<name>Apache Ivy 2.4.0</name>
<created>2014-12-26</created>
<revision>2.4.0</revision>
</Version>
</release>
<release>
<Version>
<name>Apache Ivy 2.3.0</name>
<created>2013-01-20</created>
<created>2013-01-24</created>
<revision>2.3.0</revision>
</Version>
</release>
<release>
<Version>
<name>Apache Ivy 2.2.0</name>
<created>2010-10-07</created>
<revision>2.2.0</revision>
</Version>
</release>
<release>
<Version>
<name>Apache Ivy 2.1.0</name>
<created>2009-10-13</created>
<revision>2.1.0</revision>
</Version>
</release>
<release>
<Version>
<name>Apache Ivy 2.0.0</name>
<created>2009-01-22</created>
<revision>2.0.0</revision>
</Version>
</release>
<repository>
<GitRepository>
<location rdf:resource="https://git-wip-us.apache.org/repos/asf/ant-ivy.git"/>

View File

@ -200,20 +200,27 @@ If you don't want to use xml namespaces, it's possible but you will need to disa
<span class="since">since 1.4</span>
Ivy allows the use of checksums, also known as digests, to verify the correctness of a downloaded file.
For the moment Ivy supports the md5 and sha1 algorithms.
The configuration of using md5 and/or sha1 can be done globally or by dependency resolver.
Globally, use the ivy.checksums variable to list the check to be done (only md5 and sha1 are supported).
The configuration of using the algorithm can be done globally or by dependency resolver.
Globally, use the ivy.checksums variable to list the check to be done.
On each resolver you can use the checksums attribute to override the global setting.
The setting is a comma separated list of checksum algorithms to use.
During checking (at download time), the first checksum found is checked, and that's all. This means that if you have a "sha1, md5" setting, then if ivy finds a sha1 file, it will compare the downloaded file sha1 against this sha1, and if the comparison is ok, it will assume the file is ok. If no sha1 file is found, it will look for an md5 file. If none is found no checking is done.
During checking (at download time), the first checksum found is checked, and that's all. This means that if you have a "SHA-256, sha1, md5" setting, then if ivy finds a SHA-256 file, it will compare the downloaded file SHA-256 against this SHA-256, and if the comparison is ok, it will assume the file is ok. If no SHA-256 file is found, it will look for an sha1 file. If that isn't found, then it checks for md5 and so on. If none is found no checking is done.
During publish, all listed checksum algorithms are computed and uploaded.
By default checksum algorithms are "sha1, md5".
If you want to change this default, you can set the variable ivy.checksums. Hence, to disable checksum validation you just have to set ivy.checksums to "".
<h2>Supported algorithms</h2>
<span class="since">since 1.4</span>
<ul>
<li>md5</li>
<li>sha1</li>
</ul>
<span class="since">since 2.5</span>
Starting 2.5 version, in addition to md5 and sha1, Ivy supports SHA-256, SHA-512 and SHA-384 algorithms, if the Java runtime in which Ivy is running, supports those. For example, Java 6 runtime supports SHA-256 and SHA-512 as standard algorithms. If Ivy 2.5 and later versions are run under Java 6 or higher runtimes, these algorithms are supported by Ivy too.
<h1><a name="event">Events and Triggers</a></h1>
<span class="since">since 1.4</span>
When Ivy performs the dependency resolution and some other tasks, it fires events before and after the most important steps. You can listen to these events using Ivy API, or you can even register a trigger to perform a particular action when a particular event occur.

View File

@ -51,6 +51,9 @@ In Ivy 2.1.0 and earlier, if both defaultconf and defaultconfmapping are defined
</tbody>
</table>
<h1>Child elements</h1>
Note: as specified by the ivy.xsd, the children elements are ordered; must come first the <tt><a href="../ivyfile/dependency.html">dependency</a></tt> elements, then the <tt><a href="../ivyfile/exclude.html">exclude</a></tt> elements, then the <tt><a href="../ivyfile/override.html">override</a></tt> elements, and then the <tt><a href="../ivyfile/conflict.html">conflict</a></tt> elements.
<table class="ivy-children">
<thead>
<tr><th class="ivy-chld">Element</th><th class="ivy-chld-desc">Description</th><th class="ivy-chld-card">Cardinality</th></tr>

View File

@ -47,7 +47,7 @@
<div id="footer-message" class="footer">
<hr />
<i>Copyright &#169; 2014 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0.txt">Apache License, Version 2.0</a>.</i><br />
<i>Copyright &#169; 2017 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0.txt">Apache License, Version 2.0</a>.</i><br />
<i>Apache Ivy, Apache Ant, Ivy, Ant, Apache, the Apache Ivy logo, the Apache Ant logo and the Apache feather logo are trademarks of The Apache Software Foundation.</i><br />
<i>All other marks mentioned may be trademarks or registered trademarks of their respective owners. </i>
</div>

View File

@ -36,6 +36,7 @@ reporting) project dependencies, characterized by flexibility,
configurability, and tight integration with Apache Ant.
Key features of this 2.5.0 release are
* Ivy nows uses BoucyCastle 1.52. Due to the non backward compatibility of that library, earlier versions are not supported.
* TODO
* TODO
* TODO
@ -57,7 +58,27 @@ http://issues.apache.org/jira/browse/ivy
List of changes since Ivy 2.4.0:
- FIX: Made the maven 'test' configuration public so we can use the test-jar as dependency (IVY-1444)
- FIX: NullPointerException in dependencytree with no dependencies (IVY-1539)
- FIX: checkIfChanged is not settable attribute for checkdepsupdate ant task (IVY-1549)
- FIX: ArrayIndexOutOfBoundsException when using a p2 repository for dependencies (IVY-1504)
- FIX: fixdeps remove transitive 'kept' dependencies
- FIX: PomModuleDescriptorParser should parse licenses from parent POM (IVY-1526) (Thanks to Jaikiran Pai)
- FIX: dynamic revisions are not cached per resolver (IVY-1430) (Thanks to Stephen Haberman)
- FIX: Dependencies failed using branch attribute (and extra attributes) (IVY-1141) (Thanks to Stephen Haberman)
- FIX: useCacheOnly should allow lookup of changing dependencies in cache (IVY-1515) (Thanks to Ilya)
- FIX: Translation of POM to Ivy XML with * exclusion is removing main artifact (IVY-1531) (Thanks to Jaikiran Pai)
- FIX: Have makepom task take description from ivy-module > info > description element (IVY-1520)
- FIX: Fix RetrieveEngine to take into account the correct extension while dealing with unpacked artifacts (IVY-1478) (Thanks to Jaikiran Pai)
- FIX: ParseException "Unsupported repository, resources names are not uris" for ivy.xml with parent on Windows (IVY-1448) (Thanks to Riccardo Foschia and Jaikiran Pai)
- IMPROVEMENT: Throw an IllegalStateException when retrieving the resolutionCacheRoot on the DefaultResolutionCacheManager if the basedir (or IvySettings) is not set (IVY-1482)
- IMPROVEMENT: Optimization: limit the revision numbers scanned if revision prefix is specified (Thanks to Ernestas Vaiciukevi&#269;ius)
- IMPROVEMENT: Update bouncycastle to 1.52 (IVY-1521) (Thanks to Michal Srb)
- NEW: Lets ssh-based resolvers use an ~/.ssh/config file to find username/hostname/keyfile options (Thanks to Colin Stanfill)
- NEW: Add ivy.maven.lookup.sources and ivy.maven.lookup.javadoc variables to control the lookup of the additional artifacts. Defaults to true, for backward compatibility (IVY-1529)
- NEW: Add (conditional) support for SHA-256 SHA-512 and SHA-384 checksum algorithms (IVY-1554) (Thanks to Jaikiran Pai)
<!-- Samples :
- NEW: bla bla bla (IVY-1234) (Thanks to Jane Doe)
@ -115,6 +136,7 @@ Here is the list of people who have contributed source code and documentation up
<li>Robin Fernandes</li>
<li>Gregory Fernandez</li>
<li>Danno Ferrin</li>
<li>Riccardo Foschia</li>
<li>Benjamin Francisoud</li>
<li>Wolfgang Frank</li>
<li>Jacob Grydholt Jensen</li>
@ -122,7 +144,7 @@ Here is the list of people who have contributed source code and documentation up
<li>Mitch Gitman</li>
<li>Evgeny Goldin</li>
<li>Scott Goldstein</li>
<li>Pierre Hägnestrand</li>
<li>Pierre H&#228;gnestrand</li>
<li>Scott Hebert</li>
<li>Tobias Himstedt</li>
<li>Aaron Hachez</li>
@ -132,6 +154,7 @@ Here is the list of people who have contributed source code and documentation up
<li>Scott Hebert</li>
<li>Payam Hekmat</li>
<li>Achim Huegen</li>
<li>Ilya</li>
<li>Matt Inger</li>
<li>Anders Jacobsson</li>
<li>Anders Janmyr</li>
@ -167,6 +190,7 @@ Here is the list of people who have contributed source code and documentation up
<li>Mathias Muller</li>
<li>Randy Nott</li>
<li>Peter Oxenham</li>
<li>Jaikiran Pai</li>
<li>Douglas Palmer</li>
<li>Jesper Pedersen</li>
<li>Emmanuel Pellereau</li>
@ -190,12 +214,15 @@ Here is the list of people who have contributed source code and documentation up
<li>John Shields</li>
<li>Nihal Sinha</li>
<li>Gene Smith</li>
<li>Michal Srb</li>
<li>Colin Stanfill</li>
<li>Simon Steiner</li>
<li>Johan Stuyts</li>
<li>John Tinetti</li>
<li>Erwin Tratar</li>
<li>Jason Trump</li>
<li>David Turner</li>
<li>Ernestas Vaiciukevi&#269;ius</li>
<li>Tjeerd Verhagen</li>
<li>Richard Vowles</li>
<li>Sven Walter</li>

View File

@ -39,7 +39,7 @@
</thead>
<tbody>
<tr><td>subject</td><td>Bintray username of a repository owner.</td>
<td>No, defaults to JCenter</td></tr>
<td>No, defaults to Bintray</td></tr>
<tr><td>repo</td><td>User's repository name.</td>
<td>No, defaults to JCenter</td></tr>
</tbody>

View File

@ -37,13 +37,14 @@ If your server supports ssh but not sftp, there is also an <a href="../resolver/
Note that sftp is also supported by vfs, so you can use a vfs resolver instead. The advantage of this resolver is that you have a better control over authentication, it can prompt for username/password credentials, or you can use private/public key authentication, which is not possible with the vfs resolver. When it prompts for username/password, it uses a Swing dialog, which is not possible in a headless environment. If you want to prompt for the credentials on the command line, use ant input task for example before calling ivy.
All necessary connection parameters can be set here via attributes.
All necessary connection parameters can be set here via attributes, or via an OpenSSH-style config file specified by sshConfig.
However all attributes defined in the pattern url of the resolver will have higher priority and will overwrite the values given here. To specify connection parameters in the pattern, you have to specify a full url and not just a path as pattern.
e.g. pattern="/path/to/my/repos/[artifact].[ext]" will use all connection parameters from this class
e.g. pattern="sftp://myserver.com/path/to/my/repos/[artifact].[ext]" will use all parameters from the attributes with the exception of the host, which will be "myserver.com"
e.g. pattern="sftp://user:geheim@myserver.com:8022/path/to/my/repos/[artifact].[ext]" will use only the keyFile and keyFilePassword from the attributes (if needed). Rest will come from the url.
Note that the authentication features of this resolver are exactly the same as the ssh resolver. Choosing between the two is often a matter of server implementation. If your server supports sftp, usually it's preferrable.
Internally this resolver relies on <a href="http://www.jcraft.com/jsch/">jsch</a> as ssh client, which is a popular java ssh client, used for example in eclipse.
@ -67,6 +68,9 @@ This resolver shares the <a href="../settings/resolvers.html#common">common attr
<td>No, defaults to host given on the patterns, fail if none is set</td></tr>
<tr><td>port</td><td>The port to connect to</td>
<td>No, defaults to 22</td></tr>
<tr><td>sshConfig</td><td>Path to an OpenSSH-style config file containing additional
configuration</td>
<td>No</td></tr>
</tbody>
</table>
<h1>Child elements</h1>
@ -115,6 +119,14 @@ Will connect to yourserver.com on port 8022 with user 'user' and password 'gehei
</code>
Will connect to yourserver.com on port 8022 with user 'user' and use keyFile path/to/key/file for keyFile and the value of password variable for keyFilePassword authentication for ivy files, and to myserver.com on port 8022 using user 'user' with the same keyFile/keyFilePassword pair for the artifacts.
<code type="xml">
<sftp host="myhost" sshConfig="/path/to/.ssh/config">
<ivy pattern="/path/to/ivy/[module]/ivy.xml"/>
<artifact pattern="/path/to/[organisation]/[module]/[artifact].[ext]"/>
</ssh>
</code>
Will connect to the host named by myhost according to the config file in /path/to/.ssh/config, using the hostname, username, and optionally IdentityFile specified in the config section "Host myhost". For example, if the corresponding Host section contains "Hostname yourserver.com" and "User myremoteusername", it will connect to yourserver.com using username myremoteusername.
</textarea>
<script type="text/javascript">xooki.postProcess();</script>
</body>

View File

@ -55,6 +55,10 @@ This resolver shares the <a href="../settings/resolvers.html#common">common attr
<td>No, defaults to host given on the patterns, fail if none is set</td></tr>
<tr><td>port</td><td>The port to connect to</td>
<td>No, defaults to 22</td></tr>
<tr><td>sshConfig</td><td>Path to an OpenSSH-style config file containing additional
configuration</td>
<td>No</td></tr>
<tr><td>publishPermissions</td><td>A four digit string (e.g., 0644, see "man chmod", "man open") specifying the permissions of the published files. <span class="since">(since 2.0)</span>
</td><td>No, defaults to scp standard behaviour</td></tr>
</tbody>
@ -89,6 +93,13 @@ Will connect to myhost.com using myuser and prompt for the password.
</code>
Will connect to yourserver.com on port 8022 with user geheim and use keyFile path/to/key/file for keyFile and the value of password variable for keyFilePassword authentication for ivy files, and to myserver.com on port 8022 using user geheim with the same keyFile/keyFilePassword pair for the artifacts.
<code type="xml">
<ssh host="myhost" sshConfig="/path/to/.ssh/config">
<ivy pattern="/path/to/ivy/[module]/ivy.xml"/>
<artifact pattern="/path/to/[organisation]/[module]/[artifact].[ext]"/>
</ssh>
</code>
Will connect to the host named by myhost according to the config file in /path/to/.ssh/config, using the hostname, username, and optionally IdentityFile specified in the config section "Host myhost". For example, if the corresponding Host section contains "Hostname yourserver.com" and "User myremoteusername", it will connect to yourserver.com using username myremoteusername.
</textarea>
<script type="text/javascript">xooki.postProcess();</script>
</body>

View File

@ -95,6 +95,13 @@ Any standard resolver can be used in force mode, which is used mainly to handle
By using such a resolver at the beginning of a chain, you can be sure that Ivy will pick up whatever module is available in this resolver (usually a private local build) instead of the real requested revision. This allows to handle use case like a developer working on modules A and C, where A -> B -> C, and pick up the local build for C without having to publish a local version of B.
<span class="since">since 2.0</span>
<h3>Maven</h3>
Any resolver which is able to parse a Maven pom.xml file has to detect the related sources or javadocs artifacts. This often involves sevrals network connection even if neither the sources nor the javadoc are requested to be downloaded.
<span class="since">since 2.5</span> Setting the property <tt>ivy.maven.lookup.sources<tt> to <tt>false</tt> disable the lookup of the sources artifact.
And setting the property <tt>ivy.maven.lookup.javadoc<tt> to <tt>false</tt> disable the lookup of the javadoc artifact.
<h2>Attributes</h2>
<table class="ivy-attributes">
<thead>

View File

@ -104,7 +104,7 @@
<div id="footer-message" class="footer">
<hr />
<i>Copyright &#169; 2014 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0.txt">Apache License, Version 2.0</a>.</i><br />
<i>Copyright &#169; 2017 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0.txt">Apache License, Version 2.0</a>.</i><br />
<i>Apache Ivy, Apache Ant, Ivy, Ant, Apache, the Apache Ivy logo, the Apache Ant logo and the Apache feather logo are trademarks of The Apache Software Foundation.</i><br />
<i>All other marks mentioned may be trademarks or registered trademarks of their respective owners. </i>
</div>

View File

@ -96,7 +96,7 @@ ${ivy.pom.header}
<tr><td>headerFile</td><td>the header of the generated pom file</td>
<td>No</td></tr>
<tr><td>description</td><td>The description that will be added to the generated pom. <span class="since">(since 2.2)</span></td>
<td>No, defaults to no description.</td></tr>
<td>No, defaults to no description. Since 2.5, defaults to the description in the source ivy file.</td></tr>
</tbody>
</table>
<h1>Child elements</h1>

96
ivy.xml
View File

@ -19,56 +19,54 @@
<ivy-module version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org.apache.ivy"
module="ivy"
status="integration">
<description homepage="http://ant.apache.org/ivy/">
Apache Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies.
</description>
</info>
<configurations>
<conf name="core" description="only ivy jar, without any dependencies"/>
<conf name="httpclient" extends="core" description="core + optional httpclient for better http handling"/>
<conf name="oro" extends="core" description="to use optional glob matcher"/>
<conf name="vfs" extends="core" description="core + optional VirtualFileSystem(VFS) support" />
<conf name="sftp" extends="core" description="core + optional SFTP support" />
<conf name="standalone" extends="core" description="to launch in standalone mode (from command line)"/>
<conf name="ant" extends="core" description="core + ant jar provided as a dependency"/>
<conf name="default" extends="core" description="full ivy with all dependencies"/>
<conf name="test" description="dependencies used for junit testing ivy" visibility="private" />
<conf name="source" description="ivy sources" />
</configurations>
<publications>
<artifact name="ivy" type="jar" conf="core"/>
<artifact name="ivy" type="source" ext="jar" conf="source"/>
</publications>
<dependencies>
<dependency org="org.apache.ant" name="ant" rev="1.7.1" conf="default,ant->default"/>
<dependency org="org.apache.ant" name="ant-nodeps" rev="1.7.1" conf="default"/>
<dependency org="org.apache.ant" name="ant-trax" rev="1.7.1" conf="default"/>
<dependency org="commons-httpclient" name="commons-httpclient" rev="3.0" conf="default,httpclient->runtime,master" />
<dependency org="oro" name="oro" rev="2.0.8" conf="default,oro->default"/>
<dependency org="commons-vfs" name="commons-vfs" rev="1.0" conf="default,vfs->default" />
<dependency org="com.jcraft" name="jsch" rev="0.1.50" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy" rev="0.0.6" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy.connector-factory" rev="0.0.6" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy.jsch" rev="0.0.6" conf="default,sftp->default" />
<dependency org="org.bouncycastle" name="bcpg-jdk14" rev="1.45" conf="default" />
<dependency org="org.bouncycastle" name="bcprov-jdk14" rev="1.45" conf="default" />
<info organisation="org.apache.ivy"
module="ivy"
status="integration">
<description homepage="http://ant.apache.org/ivy/">
Apache Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies.
</description>
</info>
<configurations>
<conf name="core" description="only ivy jar, without any dependencies"/>
<conf name="httpclient" extends="core" description="core + optional httpclient for better http handling"/>
<conf name="oro" extends="core" description="to use optional glob matcher"/>
<conf name="vfs" extends="core" description="core + optional VirtualFileSystem(VFS) support" />
<conf name="sftp" extends="core" description="core + optional SFTP support" />
<conf name="standalone" extends="core" description="to launch in standalone mode (from command line)"/>
<conf name="ant" extends="core" description="core + ant jar provided as a dependency"/>
<conf name="default" extends="core" description="full ivy with all dependencies"/>
<conf name="test" description="dependencies used for junit testing ivy" visibility="private" />
<conf name="source" description="ivy sources" />
</configurations>
<publications>
<artifact name="ivy" type="jar" conf="core"/>
<artifact name="ivy" type="source" ext="jar" conf="source"/>
</publications>
<dependencies>
<dependency org="org.apache.ant" name="ant" rev="1.9.9" conf="default,ant->default"/>
<dependency org="commons-httpclient" name="commons-httpclient" rev="3.0" conf="default,httpclient->runtime,master" />
<dependency org="oro" name="oro" rev="2.0.8" conf="default,oro->default"/>
<dependency org="commons-vfs" name="commons-vfs" rev="1.0" conf="default,vfs->default" />
<dependency org="com.jcraft" name="jsch" rev="0.1.54" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy" rev="0.0.9" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy.connector-factory" rev="0.0.9" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy.jsch" rev="0.0.9" conf="default,sftp->default" />
<dependency org="org.bouncycastle" name="bcpg-jdk15on" rev="1.52" conf="default" />
<dependency org="org.bouncycastle" name="bcprov-jdk15on" rev="1.52" conf="default" />
<!-- Test dependencies -->
<dependency org="junit" name="junit" rev="3.8.2" conf="test->default" />
<dependency org="commons-lang" name="commons-lang" rev="2.6" conf="test->default" />
<dependency org="org.apache.ant" name="ant-testutil" rev="1.7.0" conf="test->default" transitive="false" />
<dependency org="ant" name="ant-launcher" rev="1.6.2" conf="test->default" transitive="false"/>
<!-- Test dependencies -->
<dependency org="junit" name="junit" rev="3.8.2" conf="test->default" />
<dependency org="commons-lang" name="commons-lang" rev="2.6" conf="test->default" />
<dependency org="org.apache.ant" name="ant-testutil" rev="1.9.9" conf="test->default" transitive="false" />
<dependency org="org.apache.ant" name="ant-launcher" rev="1.9.9" conf="test->default" transitive="false"/>
<dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="test->default" transitive="false"/>
<dependency org="xmlunit" name="xmlunit" rev="1.5" conf="test->default" transitive="false"/>
<!-- This dependency is necessary for having validation in junit tests when running with JDK1.4 -->
<dependency org="xerces" name="xercesImpl" rev="2.6.2" conf="test->default" />
<dependency org="xerces" name="xmlParserAPIs" rev="2.6.2" conf="test->default" />
<dependency org="xmlunit" name="xmlunit" rev="1.6" conf="test->default" transitive="false"/>
<!-- This dependency is necessary for having validation in junit tests when running with JDK1.4 -->
<dependency org="xerces" name="xercesImpl" rev="2.6.2" conf="test->default" />
<dependency org="xerces" name="xmlParserAPIs" rev="2.6.2" conf="test->default" />
<!-- Global exclude for junit -->
<exclude org="junit" module="junit" conf="core,default,httpclient,oro,vfs,sftp,standalone,ant" />
</dependencies>
<!-- Global exclude for junit -->
<exclude org="junit" module="junit" conf="core,default,httpclient,oro,vfs,sftp,standalone,ant" />
</dependencies>
</ivy-module>

View File

@ -24,7 +24,6 @@ import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -38,6 +37,7 @@ import org.apache.ivy.core.deliver.DeliverOptions;
import org.apache.ivy.core.event.EventManager;
import org.apache.ivy.core.install.InstallEngine;
import org.apache.ivy.core.install.InstallOptions;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@ -45,6 +45,7 @@ import org.apache.ivy.core.publish.PublishEngine;
import org.apache.ivy.core.publish.PublishOptions;
import org.apache.ivy.core.report.ResolveReport;
import org.apache.ivy.core.repository.RepositoryManagementEngine;
import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolveEngine;
import org.apache.ivy.core.resolve.ResolveOptions;
@ -614,8 +615,9 @@ public class Ivy {
// PUBLISH
// ///////////////////////////////////////////////////////////////////////
public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern,
String resolverName, PublishOptions options) throws IOException {
public Collection<Artifact> publish(ModuleRevisionId mrid,
Collection<String> srcArtifactPattern, String resolverName, PublishOptions options)
throws IOException {
pushContext();
try {
return publishEngine.publish(mrid, srcArtifactPattern, resolverName, options);
@ -631,7 +633,7 @@ public class Ivy {
/**
* Sorts the collection of IvyNode from the less dependent to the more dependent
*/
public List sortNodes(Collection nodes, SortOptions options) {
public List<IvyNode> sortNodes(Collection<IvyNode> nodes, SortOptions options) {
pushContext();
try {
return getSortEngine().sortNodes(nodes, options);
@ -654,7 +656,8 @@ public class Ivy {
* if a circular dependency exists and circular dependency strategy decide to throw
* an exception
*/
public List sortModuleDescriptors(Collection moduleDescriptors, SortOptions options) {
public List<ModuleDescriptor> sortModuleDescriptors(
Collection<ModuleDescriptor> moduleDescriptors, SortOptions options) {
pushContext();
try {
return getSortEngine().sortModuleDescriptors(moduleDescriptors, options);
@ -750,7 +753,7 @@ public class Ivy {
}
}
public String[] listTokenValues(String token, Map otherTokenValues) {
public String[] listTokenValues(String token, Map<String, Object> otherTokenValues) {
pushContext();
try {
return searchEngine.listTokenValues(token, otherTokenValues);
@ -833,14 +836,12 @@ public class Ivy {
}
private void postConfigure() {
Collection triggers = settings.getTriggers();
for (Iterator iter = triggers.iterator(); iter.hasNext();) {
Trigger trigger = (Trigger) iter.next();
List<Trigger> triggers = settings.getTriggers();
for (Trigger trigger : triggers) {
eventManager.addIvyListener(trigger, trigger.getEventFilter());
}
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
for (DependencyResolver resolver : settings.getResolvers()) {
if (resolver instanceof BasicResolver) {
((BasicResolver) resolver).setEventManager(eventManager);
}

View File

@ -0,0 +1,236 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.ivy.ant;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.DownloadReport;
import org.apache.ivy.core.report.DownloadStatus;
import org.apache.ivy.core.resolve.DownloadOptions;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.ivy.plugins.resolver.AbstractWorkspaceResolver;
import org.apache.ivy.util.Message;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.resources.FileResource;
public class AntWorkspaceResolver extends DataType {
public static final class WorkspaceArtifact {
private String name;
private String type;
private String ext;
private String path;
public void setName(String name) {
this.name = name;
}
public void setType(String type) {
this.type = type;
}
public void setExt(String ext) {
this.ext = ext;
}
public void setPath(String path) {
this.path = path;
}
}
private List<ResourceCollection> allResources = new ArrayList<ResourceCollection>();
private boolean haltOnError = true;
private Resolver resolver;
private String name;
private List<WorkspaceArtifact> artifacts = new ArrayList<WorkspaceArtifact>();
public void setName(String name) {
this.name = name;
}
public void setHaltonerror(boolean haltOnError) {
this.haltOnError = haltOnError;
}
public void addConfigured(ResourceCollection resources) {
if (!resources.isFilesystemOnly()) {
throw new BuildException("Only filesystem resource collection is supported");
}
allResources.add(resources);
}
public WorkspaceArtifact createArtifact() {
WorkspaceArtifact a = new WorkspaceArtifact();
artifacts.add(a);
return a;
}
public Resolver getResolver() {
if (resolver == null) {
if (name == null) {
throw new BuildException("A name is required");
}
resolver = new Resolver();
resolver.setName(name);
}
return resolver;
}
private String getProjectName(File ivyFile) {
return ivyFile.getParentFile().getName();
}
private class Resolver extends AbstractWorkspaceResolver {
private Map<ModuleDescriptor, File> md2IvyFile;
private synchronized Map<ModuleDescriptor, File> getModuleDescriptors() {
if (md2IvyFile == null) {
md2IvyFile = new HashMap<ModuleDescriptor, File>();
for (ResourceCollection resources : allResources) {
for (Iterator it = resources.iterator(); it.hasNext();) {
File ivyFile = ((FileResource) it.next()).getFile();
try {
ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance()
.parseDescriptor(getParserSettings(), ivyFile.toURI().toURL(),
isValidate());
md2IvyFile.put(md, ivyFile);
Message.debug("Add " + md.getModuleRevisionId().getModuleId());
} catch (Exception ex) {
if (haltOnError) {
throw new BuildException("impossible to parse ivy file " + ivyFile
+ " exception=" + ex, ex);
} else {
Message.warn("impossible to parse ivy file " + ivyFile
+ " exception=" + ex.getMessage());
}
}
}
}
}
return md2IvyFile;
}
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
throws ParseException {
Map<ModuleDescriptor, File> mds = getModuleDescriptors();
for (Entry<ModuleDescriptor, File> md : mds.entrySet()) {
ResolvedModuleRevision rmr = checkCandidate(dd, md.getKey(),
getProjectName(md.getValue()));
if (rmr != null) {
return rmr;
}
}
return null;
}
@Override
protected List<Artifact> createWorkspaceArtifacts(ModuleDescriptor md) {
List<Artifact> res = new ArrayList<Artifact>();
for (WorkspaceArtifact wa : artifacts) {
String name = wa.name;
String type = wa.type;
String ext = wa.ext;
String path = wa.path;
if (name == null) {
name = md.getModuleRevisionId().getName();
}
if (type == null) {
type = "jar";
}
if (ext == null) {
ext = "jar";
}
if (path == null) {
path = "target" + File.separator + "dist" + File.separator + type + "s"
+ File.separator + name + "." + ext;
}
URL url;
File ivyFile = md2IvyFile.get(md);
File artifactFile = new File(ivyFile.getParentFile(), path);
try {
url = artifactFile.toURI().toURL();
} catch (MalformedURLException e) {
throw new RuntimeException("Unsupported file path : " + artifactFile, e);
}
res.add(new DefaultArtifact(md.getModuleRevisionId(), new Date(), name, type, ext,
url, null));
}
return res;
}
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
// Not much to do here - downloads are not required for workspace projects.
DownloadReport dr = new DownloadReport();
for (int i = 0; i < artifacts.length; i++) {
ArtifactDownloadReport adr = new ArtifactDownloadReport(artifacts[i]);
dr.addArtifactReport(adr);
URL url = artifacts[i].getUrl();
if (url == null || !url.getProtocol().equals("file")) {
// this is not an artifact managed by this resolver
adr.setDownloadStatus(DownloadStatus.FAILED);
return dr;
}
File f;
try {
f = new File(url.toURI());
} catch (URISyntaxException e) {
f = new File(url.getPath());
}
adr.setLocalFile(f);
adr.setDownloadStatus(DownloadStatus.NO);
adr.setSize(0);
Message.verbose("\t[IN WORKSPACE] " + artifacts[i]);
}
return dr;
}
}
}

View File

@ -32,7 +32,7 @@ public class FixDepsTask extends IvyPostResolveTask {
private File dest;
private List/* <Keep> */keeps = new ArrayList();
private List<Keep> keeps = new ArrayList<Keep>();
public void setToFile(File dest) {
this.dest = dest;
@ -59,6 +59,7 @@ public class FixDepsTask extends IvyPostResolveTask {
return k;
}
@Override
public void doExecute() throws BuildException {
prepareAndCheck();
@ -72,10 +73,9 @@ public class FixDepsTask extends IvyPostResolveTask {
ResolveReport report = getResolvedReport();
List/* <ModuleId> */midToKeep = new ArrayList();
for (int i = 0; i < keeps.size(); i++) {
midToKeep.add(ModuleId.newInstance(((Keep) keeps.get(i)).org,
((Keep) keeps.get(i)).module));
List<ModuleId> midToKeep = new ArrayList<ModuleId>();
for (Keep keep : keeps) {
midToKeep.add(ModuleId.newInstance(keep.org, keep.module));
}
ModuleDescriptor md = report.toFixedModuleDescriptor(getSettings(), midToKeep);

View File

@ -102,6 +102,8 @@ public class IvyAntSettings extends DataType {
private boolean autoRegistered = false;
private AntWorkspaceResolver antWorkspaceResolver;
/**
* Returns the default ivy settings of this classloader. If it doesn't exist yet, a new one is
* created using the given project to back the VariableContainer.
@ -275,6 +277,10 @@ public class IvyAntSettings extends DataType {
defineDefaultSettingFile(ivyAntVariableContainer, task);
}
if (antWorkspaceResolver != null) {
settings.addConfigured(antWorkspaceResolver.getResolver());
}
Ivy ivy = Ivy.newInstance(settings);
try {
ivy.pushContext();
@ -388,4 +394,7 @@ public class IvyAntSettings extends DataType {
URLHandlerRegistry.setDefault(dispatcher);
}
public void addConfiguredWorkspaceResolver(AntWorkspaceResolver antWorkspaceResolver) {
this.antWorkspaceResolver = antWorkspaceResolver;
}
}

View File

@ -23,7 +23,6 @@ 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.List;
import java.util.ListIterator;
@ -66,7 +65,7 @@ public class IvyBuildList extends IvyTask {
public static final String DESCRIPTOR_REQUIRED = "required";
private List buildFileSets = new ArrayList(); // List (FileSet)
private List<FileSet> buildFileSets = new ArrayList<FileSet>();
private String reference;
@ -152,6 +151,7 @@ public class IvyBuildList extends IvyTask {
this.onlydirectdep = onlydirectdep;
}
@Override
public void doExecute() throws BuildException {
if (reference == null) {
throw new BuildException("reference should be provided in ivy build list");
@ -168,12 +168,12 @@ public class IvyBuildList extends IvyTask {
Path path = new Path(getProject());
Map buildFiles = new HashMap(); // Map (ModuleDescriptor -> File buildFile)
List independent = new ArrayList();
List noDescriptor = new ArrayList();
Collection mds = new ArrayList();
Map<ModuleDescriptor, File> buildFiles = new HashMap<ModuleDescriptor, File>();
List<File> independent = new ArrayList<File>();
List<File> noDescriptor = new ArrayList<File>();
Collection<ModuleDescriptor> mds = new ArrayList<ModuleDescriptor>();
Set rootModuleNames = new LinkedHashSet();
Set<String> rootModuleNames = new LinkedHashSet<String>();
if (!"*".equals(root)) {
StringTokenizer st = new StringTokenizer(root, delimiter);
while (st.hasMoreTokens()) {
@ -181,7 +181,7 @@ public class IvyBuildList extends IvyTask {
}
}
Set leafModuleNames = new LinkedHashSet();
Set<String> leafModuleNames = new LinkedHashSet<String>();
if (!"*".equals(leaf)) {
StringTokenizer st = new StringTokenizer(leaf, delimiter);
while (st.hasMoreTokens()) {
@ -189,15 +189,14 @@ public class IvyBuildList extends IvyTask {
}
}
Set restartFromModuleNames = new LinkedHashSet();
Set<String> restartFromModuleNames = new LinkedHashSet<String>();
if (!"*".equals(restartFrom)) {
StringTokenizer st = new StringTokenizer(restartFrom, delimiter);
// Only accept one (first) module
restartFromModuleNames.add(st.nextToken());
}
for (ListIterator iter = buildFileSets.listIterator(); iter.hasNext();) {
FileSet fs = (FileSet) iter.next();
for (FileSet fs : buildFileSets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] builds = ds.getIncludedFiles();
for (int i = 0; i < builds.length; i++) {
@ -228,12 +227,12 @@ public class IvyBuildList extends IvyTask {
}
}
List leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, leafModuleNames,
"leaf");
List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, rootModuleNames,
"root");
List restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
restartFromModuleNames, "restartFrom");
List<ModuleDescriptor> leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
leafModuleNames, "leaf");
List<ModuleDescriptor> rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
rootModuleNames, "root");
List<ModuleDescriptor> restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(
mds, restartFromModuleNames, "restartFrom");
if (!rootModuleDescriptors.isEmpty()) {
Message.info("Filtering modules based on roots " + rootModuleNames);
@ -244,16 +243,14 @@ public class IvyBuildList extends IvyTask {
mds = filterModulesFromLeaf(mds, leafModuleDescriptors);
}
List sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
List<ModuleDescriptor> sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
if (!OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {
File buildFile = (File) iter.next();
for (File buildFile : noDescriptor) {
addBuildFile(path, buildFile);
}
}
for (ListIterator iter = independent.listIterator(); iter.hasNext();) {
File buildFile = (File) iter.next();
for (File buildFile : independent) {
addBuildFile(path, buildFile);
}
if (isReverse()) {
@ -264,11 +261,9 @@ public class IvyBuildList extends IvyTask {
// so they are not removed from build path.
if (!restartFromModuleDescriptors.isEmpty()) {
boolean foundRestartFrom = false;
List keptModules = new ArrayList();
ModuleDescriptor restartFromModuleDescriptor = (ModuleDescriptor) restartFromModuleDescriptors
.get(0);
for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
ModuleDescriptor md = (ModuleDescriptor) iter.next();
List<ModuleDescriptor> keptModules = new ArrayList<ModuleDescriptor>();
ModuleDescriptor restartFromModuleDescriptor = restartFromModuleDescriptors.get(0);
for (ModuleDescriptor md : sortedModules) {
if (md.equals(restartFromModuleDescriptor)) {
foundRestartFrom = true;
}
@ -279,18 +274,17 @@ public class IvyBuildList extends IvyTask {
sortedModules = keptModules;
}
StringBuffer order = new StringBuffer();
for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
ModuleDescriptor md = (ModuleDescriptor) iter.next();
for (ListIterator<ModuleDescriptor> iter = sortedModules.listIterator(); iter.hasNext();) {
ModuleDescriptor md = iter.next();
order.append(md.getModuleRevisionId().getModuleId());
if (iter.hasNext()) {
order.append(", ");
}
File buildFile = (File) buildFiles.get(md);
File buildFile = buildFiles.get(md);
addBuildFile(path, buildFile);
}
if (OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {
File buildFile = (File) iter.next();
for (File buildFile : noDescriptor) {
addBuildFile(path, buildFile);
}
}
@ -299,7 +293,7 @@ public class IvyBuildList extends IvyTask {
getProject().setProperty("ivy.sorted.modules", order.toString());
}
private void onMissingDescriptor(File buildFile, File ivyFile, List noDescriptor) {
private void onMissingDescriptor(File buildFile, File ivyFile, List<File> noDescriptor) {
if (OnMissingDescriptor.SKIP.equals(onMissingDescriptor)) {
Message.debug("skipping " + buildFile + ": descriptor " + ivyFile + " doesn't exist");
} else if (OnMissingDescriptor.FAIL.equals(onMissingDescriptor)) {
@ -323,12 +317,12 @@ public class IvyBuildList extends IvyTask {
}
}
private List convertModuleNamesToModuleDescriptors(Collection mds, Set moduleNames, String kind) {
List result = new ArrayList();
Set foundModuleNames = new HashSet();
private List<ModuleDescriptor> convertModuleNamesToModuleDescriptors(
Collection<ModuleDescriptor> mds, Set<String> moduleNames, String kind) {
List<ModuleDescriptor> result = new ArrayList<ModuleDescriptor>();
Set<String> foundModuleNames = new HashSet<String>();
for (Iterator it = mds.iterator(); it.hasNext();) {
ModuleDescriptor md = (ModuleDescriptor) it.next();
for (ModuleDescriptor md : mds) {
String name = md.getModuleRevisionId().getModuleId().getName();
if (moduleNames.contains(name)) {
foundModuleNames.add(name);
@ -337,14 +331,14 @@ public class IvyBuildList extends IvyTask {
}
if (foundModuleNames.size() < moduleNames.size()) {
Set missingModules = new HashSet(moduleNames);
Set<String> missingModules = new HashSet<String>(moduleNames);
missingModules.removeAll(foundModuleNames);
StringBuffer missingNames = new StringBuffer();
String sep = "";
for (Iterator it = missingModules.iterator(); it.hasNext();) {
for (String name : missingModules) {
missingNames.append(sep);
missingNames.append(it.next());
missingNames.append(name);
sep = ", ";
}
@ -365,20 +359,17 @@ public class IvyBuildList extends IvyTask {
* root module
* @return filtered list of modules
*/
private Collection filterModulesFromRoot(Collection mds, List rootmds) {
// Make a map of ModuleId objects -> ModuleDescriptors
Map moduleIdMap = new HashMap();
for (Iterator iter = mds.iterator(); iter.hasNext();) {
ModuleDescriptor md = ((ModuleDescriptor) iter.next());
private Collection<ModuleDescriptor> filterModulesFromRoot(Collection<ModuleDescriptor> mds,
List<ModuleDescriptor> rootmds) {
Map<ModuleId, ModuleDescriptor> moduleIdMap = new HashMap<ModuleId, ModuleDescriptor>();
for (ModuleDescriptor md : mds) {
moduleIdMap.put(md.getModuleRevisionId().getModuleId(), md);
}
// recursively process the nodes
Set toKeep = new LinkedHashSet();
Set<ModuleDescriptor> toKeep = new LinkedHashSet<ModuleDescriptor>();
Iterator it = rootmds.iterator();
while (it.hasNext()) {
ModuleDescriptor rootmd = (ModuleDescriptor) it.next();
for (ModuleDescriptor rootmd : rootmds) {
processFilterNodeFromRoot(rootmd, toKeep, moduleIdMap);
// With the excluderoot attribute set to true, take the rootmd out of the toKeep set.
if (excludeRoot) {
@ -391,8 +382,7 @@ public class IvyBuildList extends IvyTask {
}
// just for logging
for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
ModuleDescriptor md = ((ModuleDescriptor) iter.next());
for (ModuleDescriptor md : toKeep) {
Message.verbose("Kept module " + md.getModuleRevisionId().getModuleId().getName());
}
@ -411,13 +401,14 @@ public class IvyBuildList extends IvyTask {
* @param moduleIdMap
* reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
*/
private void processFilterNodeFromRoot(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
private void processFilterNodeFromRoot(ModuleDescriptor node, Set<ModuleDescriptor> toKeep,
Map<ModuleId, ModuleDescriptor> moduleIdMap) {
// toKeep.add(node);
DependencyDescriptor[] deps = node.getDependencies();
for (int i = 0; i < deps.length; i++) {
ModuleId id = deps[i].getDependencyId();
ModuleDescriptor md = (ModuleDescriptor) moduleIdMap.get(id);
ModuleDescriptor md = moduleIdMap.get(id);
// we test if this module id has a module descriptor, and if it isn't already in the
// toKeep Set, in which there's probably a circular dependency
if (md != null && !toKeep.contains(md)) {
@ -439,19 +430,16 @@ public class IvyBuildList extends IvyTask {
* leaf module
* @return filtered list of modules
*/
private Collection filterModulesFromLeaf(Collection mds, List leafmds) {
// Make a map of ModuleId objects -> ModuleDescriptors
Map moduleIdMap = new HashMap();
for (Iterator iter = mds.iterator(); iter.hasNext();) {
ModuleDescriptor md = ((ModuleDescriptor) iter.next());
private Collection<ModuleDescriptor> filterModulesFromLeaf(Collection<ModuleDescriptor> mds,
List<ModuleDescriptor> leafmds) {
Map<ModuleId, ModuleDescriptor> moduleIdMap = new HashMap<ModuleId, ModuleDescriptor>();
for (ModuleDescriptor md : mds) {
moduleIdMap.put(md.getModuleRevisionId().getModuleId(), md);
}
// recursively process the nodes
Set toKeep = new LinkedHashSet();
Iterator it = leafmds.iterator();
while (it.hasNext()) {
ModuleDescriptor leafmd = (ModuleDescriptor) it.next();
Set<ModuleDescriptor> toKeep = new LinkedHashSet<ModuleDescriptor>();
for (ModuleDescriptor leafmd : leafmds) {
// With the excludeleaf attribute set to true, take the rootmd out of the toKeep set.
if (excludeLeaf) {
Message.verbose("Excluded module "
@ -463,8 +451,7 @@ public class IvyBuildList extends IvyTask {
}
// just for logging
for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
ModuleDescriptor md = ((ModuleDescriptor) iter.next());
for (ModuleDescriptor md : toKeep) {
Message.verbose("Kept module " + md.getModuleRevisionId().getModuleId().getName());
}
@ -482,9 +469,9 @@ public class IvyBuildList extends IvyTask {
* @param moduleIdMap
* reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
*/
private void processFilterNodeFromLeaf(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
for (Iterator iter = moduleIdMap.values().iterator(); iter.hasNext();) {
ModuleDescriptor md = (ModuleDescriptor) iter.next();
private void processFilterNodeFromLeaf(ModuleDescriptor node, Set<ModuleDescriptor> toKeep,
Map<ModuleId, ModuleDescriptor> moduleIdMap) {
for (ModuleDescriptor md : moduleIdMap.values()) {
DependencyDescriptor[] deps = md.getDependencies();
for (int i = 0; i < deps.length; i++) {
ModuleId id = deps[i].getDependencyId();

View File

@ -19,6 +19,7 @@ package org.apache.ivy.ant;
import java.util.List;
import java.util.ListIterator;
import java.util.regex.Pattern;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.id.ModuleId;
@ -169,25 +170,32 @@ public class IvyBuildNumber extends IvyTask {
if (expression.equals(organisation) || expression.equals(module)
|| expression.equals(branch)) {
return exact.getMatcher(expression);
} else {
return regexp.getMatcher(expression);
}
return regexp.getMatcher(expression);
}
public String getName() {
return "buildnumber-matcher";
}
};
String revisionPattern = ".*";
if (revision.endsWith("+")) {
revisionPattern = Pattern.quote(revision.substring(0, revision.length() - 1)) + ".*";
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, branch,
revisionPattern);
ModuleRevisionId[] revisions;
if (resolver == null) {
revisions = searcher.listModules(
ModuleRevisionId.newInstance(organisation, module, branch, ".*"), patternMatcher);
revisions = searcher.listModules(mrid, patternMatcher);
} else {
DependencyResolver depResolver = settings.getResolver(resolver);
if (depResolver == null) {
throw new BuildException("Unknown resolver: " + resolver);
}
revisions = searcher.listModules(depResolver,
ModuleRevisionId.newInstance(organisation, module, branch, ".*"), patternMatcher);
revisions = searcher.listModules(depResolver, mrid, patternMatcher);
}
ArtifactInfo[] infos = new ArtifactInfo[revisions.length];

View File

@ -130,6 +130,11 @@ public class IvyConfigure extends Task {
settings.setPasswd(passwd);
}
public void addConfiguredWorkspaceResolver(AntWorkspaceResolver resolver) {
settings.addConfiguredWorkspaceResolver(resolver);
}
@Override
public void execute() throws BuildException {
String settingsId = settings.getId();
Object otherRef = getProject().getReference(settingsId);

View File

@ -18,7 +18,6 @@
package org.apache.ivy.ant;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
@ -32,13 +31,13 @@ import org.apache.tools.ant.BuildException;
public class IvyDependency {
private List/* <IvyDependencyConf> */confs = new ArrayList();
private List<IvyDependencyConf> confs = new ArrayList<IvyDependencyConf>();
private List/* <IvyDependencyArtifact> */artifacts = new ArrayList();
private List<IvyDependencyArtifact> artifacts = new ArrayList<IvyDependencyArtifact>();
private List/* <IvyDependencyExclude> */excludes = new ArrayList();
private List<IvyDependencyExclude> excludes = new ArrayList<IvyDependencyExclude>();
private List/* <IvyDependencyIncludes> */includes = new ArrayList();
private List<IvyDependencyInclude> includes = new ArrayList<IvyDependencyInclude>();
private String org;
@ -161,28 +160,20 @@ public class IvyDependency {
dd.addDependencyConfiguration(masterConf, "*");
}
Iterator itConfs = confs.iterator();
while (itConfs.hasNext()) {
IvyDependencyConf c = (IvyDependencyConf) itConfs.next();
for (IvyDependencyConf c : confs) {
c.addConf(dd, masterConf);
}
Iterator itArtifacts = artifacts.iterator();
while (itArtifacts.hasNext()) {
IvyDependencyArtifact artifact = (IvyDependencyArtifact) itArtifacts.next();
for (IvyDependencyArtifact artifact : artifacts) {
artifact.addArtifact(dd, masterConf);
}
Iterator itExcludes = excludes.iterator();
while (itExcludes.hasNext()) {
IvyDependencyExclude exclude = (IvyDependencyExclude) itExcludes.next();
for (IvyDependencyExclude exclude : excludes) {
DefaultExcludeRule rule = exclude.asRule(settings);
dd.addExcludeRule(masterConf, rule);
}
Iterator itIncludes = includes.iterator();
while (itIncludes.hasNext()) {
IvyDependencyInclude include = (IvyDependencyInclude) itIncludes.next();
for (IvyDependencyInclude include : includes) {
DefaultIncludeRule rule = include.asRule(settings);
dd.addIncludeRule(masterConf, rule);
}

View File

@ -49,7 +49,10 @@ public class IvyDependencyTree extends IvyPostResolveTask {
IvyNode dependency = (IvyNode) iterator.next();
populateDependencyTree(dependency, mrid, report);
}
printDependencies((List) dependencies.get(mrid), 0);
List dependencyList = (List) dependencies.get(mrid);
if (dependencyList != null) {
printDependencies(dependencyList, 0);
}
}
private void printDependencies(List/* <IvyNode> */dependencyList, int indent) {

View File

@ -211,4 +211,11 @@ public class IvyDependencyUpdateChecker extends IvyPostResolveTask {
this.showTransitive = showTransitive;
}
public boolean isCheckIfChanged() {
return checkIfChanged;
}
public void setCheckIfChanged(boolean checkIfChanged) {
this.checkIfChanged = checkIfChanged;
}
}

View File

@ -22,15 +22,14 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter;
import org.apache.ivy.plugins.parser.m2.PomWriterOptions;
import org.apache.ivy.plugins.parser.m2.PomWriterOptions.ExtraDependency;
import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
import org.apache.ivy.util.FileUtil;
import org.apache.tools.ant.BuildException;
@ -152,9 +151,9 @@ public class IvyMakePom extends IvyTask {
private String description;
private Collection mappings = new ArrayList();
private List<Mapping> mappings = new ArrayList<Mapping>();
private Collection dependencies = new ArrayList();
private List<Dependency> dependencies = new ArrayList<Dependency>();
public File getPomFile() {
return pomFile;
@ -240,6 +239,7 @@ public class IvyMakePom extends IvyTask {
return dependency;
}
@Override
public void doExecute() throws BuildException {
try {
if (ivyFile == null) {
@ -281,10 +281,9 @@ public class IvyMakePom extends IvyTask {
return options;
}
private Map getMappingsMap() {
Map mappingsMap = new HashMap();
for (Iterator iter = mappings.iterator(); iter.hasNext();) {
Mapping mapping = (Mapping) iter.next();
private Map<String, String> getMappingsMap() {
Map<String, String> mappingsMap = new LinkedHashMap<String, String>();
for (Mapping mapping : mappings) {
String[] mappingConfs = splitConfs(mapping.getConf());
for (int i = 0; i < mappingConfs.length; i++) {
if (!mappingsMap.containsKey(mappingConfs[i])) {
@ -295,13 +294,12 @@ public class IvyMakePom extends IvyTask {
return mappingsMap;
}
private List getDependencies() {
List result = new ArrayList();
for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
Dependency dependency = (Dependency) iter.next();
result.add(new PomWriterOptions.ExtraDependency(dependency.getGroup(), dependency
.getArtifact(), dependency.getVersion(), dependency.getScope(), dependency
.getType(), dependency.getClassifier(), dependency.getOptional()));
private List<ExtraDependency> getDependencies() {
List<ExtraDependency> result = new ArrayList<ExtraDependency>();
for (Dependency dependency : dependencies) {
result.add(new ExtraDependency(dependency.getGroup(), dependency.getArtifact(),
dependency.getVersion(), dependency.getScope(), dependency.getType(),
dependency.getClassifier(), dependency.getOptional()));
}
return result;
}

View File

@ -61,7 +61,7 @@ public class IvyPublish extends IvyTask {
private String publishResolverName = null;
private List artifactspattern = new ArrayList();
private List<String> artifactspattern = new ArrayList<String>();
private File deliveryList;
@ -81,7 +81,7 @@ public class IvyPublish extends IvyTask {
private boolean forcedeliver;
private Collection artifacts = new ArrayList();
private Collection<Artifact> artifacts = new ArrayList<Artifact>();
private String pubBranch;
@ -190,7 +190,7 @@ public class IvyPublish extends IvyTask {
}
public String getArtifactspattern() {
return (String) (artifactspattern.isEmpty() ? null : artifactspattern.get(0));
return artifactspattern.isEmpty() ? null : artifactspattern.get(0);
}
public void setArtifactspattern(String artifactsPattern) {
@ -222,6 +222,7 @@ public class IvyPublish extends IvyTask {
this.merge = merge;
}
@Override
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
@ -312,14 +313,10 @@ public class IvyPublish extends IvyTask {
mrid,
artifactspattern,
publishResolverName,
new PublishOptions()
.setPubrevision(getPubrevision())
.setPubbranch(getPubbranch())
.setSrcIvyPattern(publishivy ? srcivypattern : null)
.setStatus(getStatus())
new PublishOptions().setPubrevision(getPubrevision()).setPubbranch(getPubbranch())
.setSrcIvyPattern(publishivy ? srcivypattern : null).setStatus(getStatus())
.setPubdate(pubdate)
.setExtraArtifacts(
(Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]))
.setExtraArtifacts(artifacts.toArray(new Artifact[artifacts.size()]))
.setValidate(doValidate(settings)).setOverwrite(overwrite)
.setUpdate(update).setMerge(merge).setWarnOnMissing(warnonmissing)
.setHaltOnMissing(haltonmissing).setConfs(splitConfs(conf)));
@ -392,7 +389,7 @@ public class IvyPublish extends IvyTask {
private String type;
private Map extra = new HashMap();
private Map<String, String> extra = new HashMap<String, String>();
public String[] getConfigurations() {
return null;
@ -439,22 +436,22 @@ public class IvyPublish extends IvyTask {
}
public String getAttribute(String attName) {
return (String) extra.get(attName);
return extra.get(attName);
}
public Map getAttributes() {
public Map<String, String> getAttributes() {
return extra;
}
public String getExtraAttribute(String attName) {
return (String) extra.get(attName);
return extra.get(attName);
}
public Map getExtraAttributes() {
public Map<String, String> getExtraAttributes() {
return extra;
}
public Map getQualifiedExtraAttributes() {
public Map<String, String> getQualifiedExtraAttributes() {
return extra;
}

View File

@ -23,7 +23,6 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.ivy.Ivy;
@ -91,11 +90,11 @@ public class IvyResolve extends IvyTask {
private boolean checkIfChanged = true; // for backward compatibility
private List/* <IvyDependency> */dependencies = new ArrayList();
private List<IvyDependency> dependencies = new ArrayList<IvyDependency>();
private List/* <IvyExclude> */excludes = new ArrayList();
private List<IvyExclude> excludes = new ArrayList<IvyExclude>();
private List/* <IvyConflict> */conflicts = new ArrayList();
private List<IvyConflict> conflicts = new ArrayList<IvyConflict>();
public boolean isUseOrigin() {
return useOrigin;
@ -229,11 +228,13 @@ public class IvyResolve extends IvyTask {
return c;
}
@Override
protected void prepareTask() {
super.prepareTask();
Message.setShowProgress(showProgress);
}
@Override
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
@ -267,24 +268,18 @@ public class IvyResolve extends IvyTask {
Ivy.getWorkingRevision());
DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(mrid, null);
Iterator itDeps = dependencies.iterator();
while (itDeps.hasNext()) {
IvyDependency dep = (IvyDependency) itDeps.next();
for (IvyDependency dep : dependencies) {
DependencyDescriptor dd = dep.asDependencyDescriptor(md, "default", settings);
md.addDependency(dd);
}
Iterator itExcludes = excludes.iterator();
while (itExcludes.hasNext()) {
IvyExclude exclude = (IvyExclude) itExcludes.next();
for (IvyExclude exclude : excludes) {
DefaultExcludeRule rule = exclude.asRule(settings);
rule.addConfiguration("default");
md.addExcludeRule(rule);
}
Iterator itConflicts = conflicts.iterator();
while (itConflicts.hasNext()) {
IvyConflict conflict = (IvyConflict) itConflicts.next();
for (IvyConflict conflict : conflicts) {
conflict.addConflict(md, settings);
}
@ -426,9 +421,9 @@ public class IvyResolve extends IvyTask {
}
}
protected Collection/* <String> */getAllowedLogOptions() {
return Arrays.asList(new String[] {LogOptions.LOG_DEFAULT, LogOptions.LOG_DOWNLOAD_ONLY,
LogOptions.LOG_QUIET});
protected Collection<String> getAllowedLogOptions() {
return Arrays.asList(LogOptions.LOG_DEFAULT, LogOptions.LOG_DOWNLOAD_ONLY,
LogOptions.LOG_QUIET);
}
private ResolveOptions getResolveOptions(Ivy ivy, String[] confs, IvySettings settings) {

View File

@ -265,6 +265,7 @@ public abstract class IvyTask extends Task {
/**
* Ant task execute. Calls prepareTask, doExecute, finalzeTask
*/
@Override
public final void execute() throws BuildException {
try {
prepareTask();
@ -282,6 +283,7 @@ public abstract class IvyTask extends Task {
*/
public abstract void doExecute() throws BuildException;
@Override
public String toString() {
return getClass().getName() + ":" + getTaskName();
}

View File

@ -49,4 +49,5 @@
<taskdef name="fixdeps" classname="org.apache.ivy.ant.FixDepsTask" />
<taskdef name="dependencytree" classname="org.apache.ivy.ant.IvyDependencyTree"/>
<taskdef name="checkdepsupdate" classname="org.apache.ivy.ant.IvyDependencyUpdateChecker"/>
<typedef name="workspaceresolver" classname="org.apache.ivy.ant.AntWorkspaceResolver" />
</antlib>

View File

@ -32,6 +32,8 @@ public class CacheMetadataOptions extends CacheDownloadOptions {
private boolean checkTTL = true;
private boolean useCacheOnly = false;
public Namespace getNamespace() {
return namespace;
}
@ -85,4 +87,13 @@ public class CacheMetadataOptions extends CacheDownloadOptions {
public boolean isCheckTTL() {
return checkTTL;
}
public CacheMetadataOptions setUseCacheOnly(boolean useCacheOnly) {
this.useCacheOnly = useCacheOnly;
return this;
}
public boolean isUseCacheOnly() {
return useCacheOnly;
}
}

View File

@ -26,7 +26,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.regex.Pattern;
@ -114,7 +113,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
private Boolean useOrigin;
private ModuleRules/* <Long> */ttlRules = new ModuleRules();
private ModuleRules<Long> ttlRules = new ModuleRules<Long>();
private Long defaultTTL = null;
@ -188,17 +187,17 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
public long getDefaultTTL() {
if (defaultTTL == null) {
defaultTTL = new Long(parseDuration(settings.getVariable("ivy.cache.ttl.default")));
defaultTTL = Long.valueOf(parseDuration(settings.getVariable("ivy.cache.ttl.default")));
}
return defaultTTL.longValue();
}
public void setDefaultTTL(long defaultTTL) {
this.defaultTTL = new Long(defaultTTL);
this.defaultTTL = Long.valueOf(defaultTTL);
}
public void setDefaultTTL(String defaultTTL) {
this.defaultTTL = new Long(parseDuration(defaultTTL));
this.defaultTTL = Long.valueOf(parseDuration(defaultTTL));
}
public String getDataFilePattern() {
@ -239,16 +238,16 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
this.changingPattern = changingPattern;
}
public void addTTL(Map attributes, PatternMatcher matcher, long duration) {
public void addTTL(Map<String, String> attributes, PatternMatcher matcher, long duration) {
ttlRules.defineRule(new MapMatcher(attributes, matcher), new Long(duration));
}
public void addConfiguredTtl(Map/* <String,String> */attributes) {
String duration = (String) attributes.remove("duration");
public void addConfiguredTtl(Map<String, String> attributes) {
String duration = attributes.remove("duration");
if (duration == null) {
throw new IllegalArgumentException("'duration' attribute is mandatory for ttl");
}
String matcher = (String) attributes.remove("matcher");
String matcher = attributes.remove("matcher");
addTTL(attributes,
matcher == null ? ExactPatternMatcher.INSTANCE : settings.getMatcher(matcher),
parseDuration(duration));
@ -295,10 +294,9 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
return days * MILLIS_IN_DAY + hours * MILLIS_IN_HOUR + minutes * MILLIS_IN_MINUTES
+ seconds * MILLIS_IN_SECONDS + millis;
} else {
throw new IllegalArgumentException("invalid duration '" + duration
+ "': it must match " + DURATION_PATTERN.pattern() + " or 'eternal'");
}
throw new IllegalArgumentException("invalid duration '" + duration
+ "': it must match " + DURATION_PATTERN.pattern() + " or 'eternal'");
}
private int getGroupIntValue(java.util.regex.Matcher m, int groupNumber) {
@ -309,19 +307,14 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
/**
* True if this cache should check lastmodified date to know if ivy files are up to date.
*
* @return
* @return boolean
*/
public boolean isCheckmodified() {
if (checkmodified == null) {
if (getSettings() != null) {
String check = getSettings().getVariable("ivy.resolver.default.check.modified");
return check != null ? Boolean.valueOf(check).booleanValue() : false;
} else {
return false;
}
} else {
return checkmodified.booleanValue();
return getSettings() != null && Boolean
.parseBoolean(getSettings().getVariable("ivy.resolver.default.check.modified"));
}
return checkmodified.booleanValue();
}
public void setCheckmodified(boolean check) {
@ -334,14 +327,9 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
*/
public boolean isUseOrigin() {
if (useOrigin == null) {
if (getSettings() != null) {
return getSettings().isDefaultUseOrigin();
} else {
return false;
}
} else {
return useOrigin.booleanValue();
return getSettings() != null && getSettings().isDefaultUseOrigin();
}
return useOrigin.booleanValue();
}
public void setUseOrigin(boolean b) {
@ -384,9 +372,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
private File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin) {
if (useOrigin && !ArtifactOrigin.isUnknown(origin) && origin.isLocal()) {
return Checks.checkAbsolute(origin.getLocation(), artifact + " origin location");
} else {
return new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
}
return new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
}
public String getArchivePathInCache(Artifact artifact) {
@ -396,9 +383,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
public String getArchivePathInCache(Artifact artifact, ArtifactOrigin origin) {
if (isOriginalMetadataArtifact(artifact)) {
return IvyPatternHelper.substitute(getIvyPattern() + ".original", artifact, origin);
} else {
return IvyPatternHelper.substitute(getArtifactPattern(), artifact, origin);
}
return IvyPatternHelper.substitute(getArtifactPattern(), artifact, origin);
}
/**
@ -423,7 +409,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
*
* @param md
* the module descriptor resolved
* @param name
* @param artifactResolverName
* artifact resolver name
*/
public void saveResolvers(ModuleDescriptor md, String metadataResolverName,
@ -531,10 +517,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
// try to find other cached artifact info with same location. This must be the
// origin. We must parse the key as we do not know for sure what the original
// artifact is named.
Iterator it = cdf.entrySet().iterator();
String ownLocationKey = getLocationKey(artifact);
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
for (Map.Entry<Object, Object> entry : cdf.entrySet()) {
if (entry.getValue().equals(location)
&& !ownLocationKey.equals(entry.getKey())) {
// found a match, key is
@ -576,7 +560,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
origin.setLastChecked(Long.valueOf(lastChecked));
}
if (exists != null) {
origin.setExist(Boolean.valueOf(exists).booleanValue());
origin.setExist(Boolean.parseBoolean(exists));
}
return origin;
@ -669,6 +653,17 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
getDataFilePattern(), mRevId)), "ivy cached data file for " + mRevId);
}
/**
* A resolver-specific ivydata file, only used for caching dynamic revisions, e.g.
* integration-repo.
*/
private PropertiesFile getCachedDataFile(String resolverName, ModuleRevisionId mRevId) {
// we append ".${resolverName} onto the end of the regular ivydata location
return new PropertiesFile(new File(getRepositoryCacheRoot(),
IvyPatternHelper.substitute(getDataFilePattern(), mRevId) + "." + resolverName),
"ivy cached data file for " + mRevId);
}
public ResolvedModuleRevision findModuleInCache(DependencyDescriptor dd,
ModuleRevisionId requestedRevisionId, CacheMetadataOptions options,
String expectedResolver) {
@ -677,7 +672,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
Message.verbose("don't use cache for " + mrid + ": checkModified=true");
return null;
}
if (isChanging(dd, requestedRevisionId, options)) {
if (!options.isUseCacheOnly() && isChanging(dd, requestedRevisionId, options)) {
Message.verbose("don't use cache for " + mrid + ": changing=true");
return null;
}
@ -695,25 +690,24 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
try {
if (settings.getVersionMatcher().isDynamic(mrid)) {
String resolvedRevision = getResolvedRevision(mrid, options);
if (resolvedRevision != null) {
Message.verbose("found resolved revision in cache: " + mrid + " => "
+ resolvedRevision);
String resolvedRevision = getResolvedRevision(expectedResolver, mrid, options);
if (resolvedRevision == null) {
return null;
}
Message.verbose("found resolved revision in cache: " + mrid + " => "
+ resolvedRevision);
// we have found another module in the cache, make sure we unlock
// the original module
unlockMetadataArtifact(mrid);
mrid = ModuleRevisionId.newInstance(mrid, resolvedRevision);
// we have found another module in the cache, make sure we unlock
// the original module
unlockMetadataArtifact(mrid);
mrid = ModuleRevisionId.newInstance(mrid, resolvedRevision);
// don't forget to request a lock on the new module!
if (!lockMetadataArtifact(mrid)) {
Message.error("impossible to acquire lock for " + mrid);
// don't forget to request a lock on the new module!
if (!lockMetadataArtifact(mrid)) {
Message.error("impossible to acquire lock for " + mrid);
// we couldn't lock the new module, so no need to unlock it
unlock = false;
return null;
}
} else {
// we couldn't lock the new module, so no need to unlock it
unlock = false;
return null;
}
}
@ -766,11 +760,10 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
}
}
return new ResolvedModuleRevision(resolver, artResolver, depMD, madr);
} else {
Message.debug("found module in cache but with a different resolver: "
+ "discarding: " + mrid + "; expected resolver="
+ expectedResolver + "; resolver=" + resolver.getName());
}
Message.debug("found module in cache but with a different resolver: "
+ "discarding: " + mrid + "; expected resolver="
+ expectedResolver + "; resolver=" + resolver.getName());
} else {
Message.debug("\tresolver not found: " + resolverName
+ " => cannot use cached ivy file for " + mrid);
@ -834,19 +827,28 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
return cache.getStale(ivyFile, settings, options.isValidate(), mdProvider);
}
private String getResolvedRevision(ModuleRevisionId mrid, CacheMetadataOptions options) {
/**
* Called by doFindModuleInCache to lookup the dynamic {@code mrid} in the ivycache's ivydata
* file.
*/
private String getResolvedRevision(String expectedResolver, ModuleRevisionId mrid, CacheMetadataOptions options) {
if (!lockMetadataArtifact(mrid)) {
Message.error("impossible to acquire lock for " + mrid);
return null;
}
try {
String resolvedRevision = null;
if (options.isForce()) {
Message.verbose("refresh mode: no check for cached resolved revision for " + mrid);
return null;
}
PropertiesFile cachedResolvedRevision = getCachedDataFile(mrid);
resolvedRevision = cachedResolvedRevision.getProperty("resolved.revision");
// If a resolver is asking for its specific dynamic revision, avoid looking at a different one
PropertiesFile cachedResolvedRevision;
if (expectedResolver != null) {
cachedResolvedRevision = getCachedDataFile(expectedResolver, mrid);
} else {
cachedResolvedRevision = getCachedDataFile(mrid);
}
String resolvedRevision = cachedResolvedRevision.getProperty("resolved.revision");
if (resolvedRevision == null) {
Message.verbose(getName() + ": no cached resolved revision for " + mrid);
return null;
@ -875,15 +877,27 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
}
public void saveResolvedRevision(ModuleRevisionId mrid, String revision) {
saveResolvedRevision(null, mrid, revision);
}
public void saveResolvedRevision(String resolverName, ModuleRevisionId mrid, String revision) {
if (!lockMetadataArtifact(mrid)) {
Message.error("impossible to acquire lock for " + mrid);
return;
}
try {
PropertiesFile cachedResolvedRevision = getCachedDataFile(mrid);
PropertiesFile cachedResolvedRevision;
if (resolverName == null) {
cachedResolvedRevision = getCachedDataFile(mrid);
} else {
cachedResolvedRevision = getCachedDataFile(resolverName, mrid);
}
cachedResolvedRevision.setProperty("resolved.time",
String.valueOf(System.currentTimeMillis()));
cachedResolvedRevision.setProperty("resolved.revision", revision);
if (resolverName != null) {
cachedResolvedRevision.setProperty("resolver", resolverName);
}
cachedResolvedRevision.save();
} finally {
unlockMetadataArtifact(mrid);
@ -891,10 +905,11 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
}
public long getTTL(ModuleRevisionId mrid) {
Long ttl = (Long) ttlRules.getRule(mrid);
Long ttl = ttlRules.getRule(mrid);
return ttl == null ? getDefaultTTL() : ttl.longValue();
}
@Override
public String toString() {
return name;
}
@ -1028,11 +1043,13 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
File archiveFile = getArchiveFileInCache(unpacked, null, false);
if (archiveFile.exists() && !options.isForce()) {
adr.setUnpackedLocalFile(archiveFile);
adr.setUnpackedArtifact(unpacked);
} else {
Message.info("\tUnpacking " + artifact.getId());
try {
packagingManager.unpackArtifact(artifact, adr.getLocalFile(), archiveFile);
final Artifact unpackedArtifact = packagingManager.unpackArtifact(artifact, adr.getLocalFile(), archiveFile);
adr.setUnpackedLocalFile(archiveFile);
adr.setUnpackedArtifact(unpackedArtifact);
} catch (Exception e) {
Message.debug(e);
adr.setDownloadStatus(DownloadStatus.FAILED);
@ -1141,13 +1158,12 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
* @return the hash
*/
private String computeResourceNameHash(Resource resource) {
byte[] shaDigest;
try {
shaDigest = SHA_DIGEST.digest(resource.getName().getBytes("UTF-8"));
byte[] shaDigest = SHA_DIGEST.digest(resource.getName().getBytes("UTF-8"));
return HexEncoder.encode(shaDigest);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("UTF-8 not supported", e);
}
return HexEncoder.encode(shaDigest);
}
/**
@ -1171,18 +1187,13 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
if (savedOrigin.getLastChecked() != null
&& (time - savedOrigin.getLastChecked().longValue()) < ttl) {
// still in the ttl period, no need to check, trust the cache
if (!archiveFile.exists()) {
// but if the local archive doesn't exist, trust the cache only if the cached origin
// says that the remote resource doesn't exist either
return !savedOrigin.isExists();
}
return true;
return archiveFile.exists() || !savedOrigin.isExists();
}
if (!archiveFile.exists()) {
// the the file doesn't exist in the cache, obviously not up to date
return false;
}
origin.setLastChecked(new Long(time));
origin.setLastChecked(Long.valueOf(time));
// check if the local resource is up to date regarding the remote one
return archiveFile.lastModified() >= resource.getLastModified();
}
@ -1285,16 +1296,15 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
+ mrid);
rmr.getReport().setSearched(true);
return rmr;
} else {
Message.verbose("\t" + getName()
+ ": revision in cache is not up to date: " + mrid);
if (isChanging(dd, mrid, options)) {
// ivy file has been updated, we should see if it has a new publication
// date to see if a new download is required (in case the dependency is
// a changing one)
cachedPublicationDate = rmr.getDescriptor()
.getResolvedPublicationDate();
}
}
Message.verbose("\t" + getName()
+ ": revision in cache is not up to date: " + mrid);
if (isChanging(dd, mrid, options)) {
// ivy file has been updated, we should see if it has a new publication
// date to see if a new download is required (in case the dependency is
// a changing one)
cachedPublicationDate = rmr.getDescriptor()
.getResolvedPublicationDate();
}
}
}
@ -1327,9 +1337,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
parserSettings);
if (md == null) {
throw new IllegalStateException(
"module descriptor parser returned a null module descriptor, "
+ "which is not allowed. " + "parser=" + parser
+ "; parser class=" + parser.getClass().getName()
"module descriptor parser returned a null module descriptor, which is not allowed. parser="
+ parser + "; parser class=" + parser.getClass().getName()
+ "; module descriptor resource=" + mdRef.getResource());
}
Message.debug("\t" + getName() + ": parsed downloaded md file for " + mrid
@ -1344,11 +1353,9 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
deleteOldArtifacts = true;
}
if (deleteOldArtifacts) {
String[] confs = md.getConfigurationsNames();
for (int i = 0; i < confs.length; i++) {
Artifact[] arts = md.getArtifacts(confs[i]);
for (int j = 0; j < arts.length; j++) {
Artifact transformedArtifact = NameSpaceHelper.transform(arts[j],
for (String conf : md.getConfigurationsNames()) {
for (Artifact art : md.getArtifacts(conf)) {
Artifact transformedArtifact = NameSpaceHelper.transform(art,
options.getNamespace().getToSystemTransformer());
ArtifactOrigin origin = getSavedArtifactOrigin(transformedArtifact);
File artFile = getArchiveFileInCache(transformedArtifact, origin, false);
@ -1430,7 +1437,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
return new DefaultArtifact(mrid, new Date(), "metadata", "metadata", "ivy", true);
}
// not used any more, but maybe useful for finer grain locking when downloading artifacts
// not used any more, but may be useful for finer grained locking when downloading artifacts
// private boolean lockArtifact(Artifact artifact) {
// try {
// return getLockStrategy().lockArtifact(artifact,

View File

@ -74,6 +74,12 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv
}
public File getResolutionCacheRoot() {
if (basedir == null) {
if (settings == null) {
throw new IllegalStateException("The 'basedir' or 'IvySettings' has not been set on the ResolutionCacheManager");
}
basedir = settings.getDefaultResolutionCacheBasedir();
}
return basedir;
}
@ -213,7 +219,7 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv
}
public void clean() {
FileUtil.forceDelete(getBasedir());
FileUtil.forceDelete(getResolutionCacheRoot());
}
private static class CacheParserSettings implements ParserSettings {
@ -274,6 +280,10 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv
public Namespace getContextNamespace() {
return delegate.getContextNamespace();
}
public String getVariable(String value) {
return delegate.getVariable(value);
}
}
private static class MapURLResolver extends RelativeUrlResolver {

View File

@ -150,5 +150,9 @@ class ParserSettingsMonitor {
}
return r;
}
public String getVariable(String value) {
return delegatedSettings.getVariable(value);
}
};
}

View File

@ -188,7 +188,22 @@ public interface RepositoryCacheManager {
* the dynamic module revision id
* @param revision
* the resolved revision
* @deprecated See {@link #saveResolvedRevision(String, ModuleRevisionId, String)} which
* prevents cache + * thrashing when multiple resolvers store the same dynamicMrid
*/
public void saveResolvedRevision(ModuleRevisionId dynamicMrid, String revision);
/**
* Caches a dynamic revision constraint resolution for a specific resolver.
*
* @param resolverName
* the resolver in which this dynamic revision was resolved
* @param dynamicMrid
* the dynamic module revision id
* @param revision
* the resolved revision
*/
public void saveResolvedRevision(String resolverName, ModuleRevisionId dynamicMrid,
String revision);
}

View File

@ -52,14 +52,15 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
this.name = name;
}
@Override
public String toString() {
return name;
}
}
public static Collection/* <Configuration> */findConfigurationExtending(String conf,
public static Collection<Configuration> findConfigurationExtending(String conf,
Configuration[] confs) {
Collection extendingConfs = new ArrayList();
Collection<Configuration> extendingConfs = new ArrayList<Configuration>();
for (int i = 0; i < confs.length; i++) {
if (confs[i] != null && Arrays.asList(confs[i].getExtends()).contains(conf)) {
extendingConfs.add(confs[i]);
@ -120,9 +121,9 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
this(null, null, name, visibility, description, ext, transitive, deprecated, null);
}
private Configuration(Map attributes, Map extraAttributes, String name, Visibility visibility,
String description, String[] ext, boolean transitive, String deprecated,
ModuleRevisionId sourceModule) {
private Configuration(Map<String, String> attributes, Map<String, String> extraAttributes,
String name, Visibility visibility, String description, String[] ext,
boolean transitive, String deprecated, ModuleRevisionId sourceModule) {
super(attributes, extraAttributes);
if (name == null) {
@ -195,10 +196,12 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
return sourceModule;
}
@Override
public String toString() {
return name;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Configuration)) {
return false;
@ -206,6 +209,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
return ((Configuration) obj).getName().equals(getName());
}
@Override
public int hashCode() {
return getName().hashCode();
}
@ -218,7 +222,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
Configuration[] configs = md.getConfigurations();
Set newExtends = new LinkedHashSet();
Set<String> newExtends = new LinkedHashSet<String>();
for (int j = 0; j < extendsFrom.length; j++) {
if ("*".equals(extendsFrom[j])) {
addOther(configs, null, newExtends);
@ -231,10 +235,10 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
}
}
this.extendsFrom = (String[]) newExtends.toArray(new String[newExtends.size()]);
this.extendsFrom = newExtends.toArray(new String[newExtends.size()]);
}
private void addOther(Configuration[] allConfigs, Visibility visibility, Set configs) {
private void addOther(Configuration[] allConfigs, Visibility visibility, Set<String> configs) {
for (int i = 0; i < allConfigs.length; i++) {
String currentName = allConfigs[i].getName();
if (!name.equals(currentName)

View File

@ -25,7 +25,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@ -210,13 +209,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
private Date resolvedPublicationDate;
private List dependencies = new ArrayList(); // List (DependencyDescriptor)
private List<DependencyDescriptor> dependencies = new ArrayList<DependencyDescriptor>();
private Map configurations = new LinkedHashMap(); // Map(String conf -> Configuration)
private Map<String, Configuration> configurations = new LinkedHashMap<String, Configuration>();
private Map artifactsByConf = new HashMap(); // Map (String conf -> Collection(Artifact))
private Map<String, Collection<Artifact>> artifactsByConf = new HashMap<String, Collection<Artifact>>();
private Collection artifacts = new LinkedHashSet(); // Collection(Artifact)
private Collection<Artifact> artifacts = new LinkedHashSet<Artifact>();
// all artifacts could also be found in the artifactsByConf map, but here we can
// preserve the order
@ -227,7 +226,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
private ModuleRules dependencyDescriptorMediators = new ModuleRules();
private List licenses = new ArrayList(); // List(License)
private List<License> licenses = new ArrayList<License>();
private String homePage;
@ -247,13 +246,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
private Resource resource;
private List excludeRules = new ArrayList(); // List(ExcludeRule)
private List<ExcludeRule> excludeRules = new ArrayList<ExcludeRule>();
private Artifact metadataArtifact;
private List inheritedDescriptors = new ArrayList(); // List(ExtendsDescriptor)
private List<ExtendsDescriptor> inheritedDescriptors = new ArrayList<ExtendsDescriptor>();
private Map/* <String,String> */extraAttributesNamespaces = new LinkedHashMap();
private Map<String, String> extraAttributesNamespaces = new LinkedHashMap<String, String>();
private List<ExtraInfoHolder> extraInfos = new ArrayList<ExtraInfoHolder>();
@ -381,9 +380,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
addArtifact(members[i], artifact);
}
} else {
Collection artifacts = (Collection) artifactsByConf.get(conf);
Collection<Artifact> artifacts = artifactsByConf.get(conf);
if (artifacts == null) {
artifacts = new ArrayList();
artifacts = new ArrayList<Artifact>();
artifactsByConf.put(conf, artifacts);
}
artifacts.add(artifact);
@ -404,28 +403,25 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
public ExtendsDescriptor[] getInheritedDescriptors() {
return (ExtendsDescriptor[]) inheritedDescriptors
.toArray(new ExtendsDescriptor[inheritedDescriptors.size()]);
return inheritedDescriptors.toArray(new ExtendsDescriptor[inheritedDescriptors.size()]);
}
public Configuration[] getConfigurations() {
return (Configuration[]) configurations.values().toArray(
new Configuration[configurations.size()]);
return configurations.values().toArray(new Configuration[configurations.size()]);
}
public String[] getConfigurationsNames() {
return (String[]) configurations.keySet().toArray(new String[configurations.size()]);
return configurations.keySet().toArray(new String[configurations.size()]);
}
public String[] getPublicConfigurationsNames() {
List ret = new ArrayList();
for (Iterator iter = configurations.values().iterator(); iter.hasNext();) {
Configuration conf = (Configuration) iter.next();
List<String> ret = new ArrayList<String>();
for (Configuration conf : configurations.values()) {
if (conf.getVisibility() == Configuration.Visibility.PUBLIC) {
ret.add(conf.getName());
}
}
return (String[]) ret.toArray(new String[ret.size()]);
return ret.toArray(new String[ret.size()]);
}
/**
@ -433,7 +429,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
* if not found.
*/
public Configuration getConfiguration(String confName) {
Configuration configuration = (Configuration) configurations.get(confName);
Configuration configuration = configurations.get(confName);
if (configuration == null && confName != null) {
// let's first check if the configuration is a conf group
Matcher m = Pattern.compile("\\*\\[([^=]+)\\=([^\\]]+)\\]").matcher(confName);
@ -442,9 +438,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
String attValue = m.group(2);
// this is a conf group, let's search for its members
Map /* <String,Configuration> */members = new LinkedHashMap();
for (Iterator it = configurations.values().iterator(); it.hasNext();) {
Configuration conf = (Configuration) it.next();
Map<String, Configuration> members = new LinkedHashMap<String, Configuration>();
for (Configuration conf : configurations.values()) {
if (attValue.equals(conf.getAttribute(attName))) {
members.put(conf.getName(), conf);
}
@ -457,9 +452,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
if (confs.length <= 1) {
return null;
}
Map /* <String,Configuration> */intersectedConfs = new LinkedHashMap();
Map<String, Configuration> intersectedConfs = new LinkedHashMap<String, Configuration>();
for (int i = 0; i < confs.length; i++) {
Configuration c = (Configuration) configurations.get(confs[i]);
Configuration c = configurations.get(confs[i]);
if (c == null) {
Message.verbose("missing configuration '" + confs[i] + "' from intersection "
+ confName + " in " + this);
@ -477,13 +472,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
if (c == null) {
return new Artifact[0];
}
Collection artifacts = (Collection) artifactsByConf.get(conf);
Collection<Artifact> artifacts = artifactsByConf.get(conf);
if (c instanceof ConfigurationIntersection) {
ConfigurationIntersection intersection = (ConfigurationIntersection) c;
String[] intersected = intersection.getIntersectedConfigurationNames();
Set/* <Artifact> */intersectedArtifacts = new LinkedHashSet();
Set<Artifact> intersectedArtifacts = new LinkedHashSet<Artifact>();
for (int j = 0; j < intersected.length; j++) {
Collection arts = getArtifactsIncludingExtending(intersected[j]);
Collection<Artifact> arts = getArtifactsIncludingExtending(intersected[j]);
if (intersectedArtifacts.isEmpty()) {
intersectedArtifacts.addAll(arts);
} else {
@ -493,39 +488,37 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
if (artifacts != null) {
intersectedArtifacts.addAll(artifacts);
}
return (Artifact[]) intersectedArtifacts.toArray(new Artifact[intersectedArtifacts
.size()]);
return intersectedArtifacts.toArray(new Artifact[intersectedArtifacts.size()]);
} else if (c instanceof ConfigurationGroup) {
ConfigurationGroup group = (ConfigurationGroup) c;
String[] members = group.getMembersConfigurationNames();
Set/* <Artifact> */groupArtifacts = new LinkedHashSet();
Set<Artifact> groupArtifacts = new LinkedHashSet<Artifact>();
for (int i = 0; i < members.length; i++) {
groupArtifacts.addAll(getArtifactsIncludingExtending(members[i]));
}
if (artifacts != null) {
groupArtifacts.addAll(artifacts);
}
return (Artifact[]) groupArtifacts.toArray(new Artifact[groupArtifacts.size()]);
return groupArtifacts.toArray(new Artifact[groupArtifacts.size()]);
} else {
if (artifacts == null) {
return new Artifact[0];
} else {
return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
return artifacts.toArray(new Artifact[artifacts.size()]);
}
}
}
private Collection/* <Artifact> */getArtifactsIncludingExtending(String conf) {
Collection extendingConfs = Configuration.findConfigurationExtending(conf,
private Collection<Artifact> getArtifactsIncludingExtending(String conf) {
Collection<Configuration> extendingConfs = Configuration.findConfigurationExtending(conf,
getConfigurations());
Set/* <Artifact> */artifacts = new LinkedHashSet();
Collection arts = (Collection) artifactsByConf.get(conf);
Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
Collection<Artifact> arts = artifactsByConf.get(conf);
if (arts != null) {
artifacts.addAll(arts);
}
for (Iterator it = extendingConfs.iterator(); it.hasNext();) {
Configuration extendingConf = (Configuration) it.next();
arts = (Collection) artifactsByConf.get(extendingConf.getName());
for (Configuration extendingConf : extendingConfs) {
arts = artifactsByConf.get(extendingConf.getName());
if (arts != null) {
artifacts.addAll(arts);
}
@ -534,17 +527,15 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
public Artifact[] getAllArtifacts() {
return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
return artifacts.toArray(new Artifact[artifacts.size()]);
}
public DependencyDescriptor[] getDependencies() {
return (DependencyDescriptor[]) dependencies.toArray(new DependencyDescriptor[dependencies
.size()]);
return dependencies.toArray(new DependencyDescriptor[dependencies.size()]);
}
public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md) {
for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
DependencyDescriptor dd = (DependencyDescriptor) iter.next();
for (DependencyDescriptor dd : dependencies) {
if (dd.getDependencyId().equals(md.getModuleRevisionId().getModuleId())) {
if (md.getResolvedModuleRevisionId().getRevision() == null) {
return true;
@ -564,6 +555,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
@ -571,6 +563,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
@ -592,6 +585,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
return true;
}
@Override
public String toString() {
return "module: " + revId + " status=" + status + " publication=" + publicationDate
+ " configurations=" + configurations + " artifacts=" + artifactsByConf
@ -633,7 +627,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
return dd;
}
public ModuleRules/* <DependencyDescriptorMediator> */getAllDependencyDescriptorMediators() {
public ModuleRules getAllDependencyDescriptorMediators() {
return (ModuleRules) dependencyDescriptorMediators.clone();
}
@ -642,7 +636,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
public License[] getLicenses() {
return (License[]) licenses.toArray(new License[licenses.size()]);
return licenses.toArray(new License[licenses.size()]);
}
public String getHomePage() {
@ -674,8 +668,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
public boolean isNamespaceUseful() {
for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
DependencyDescriptor dd = (DependencyDescriptor) iter.next();
for (DependencyDescriptor dd : dependencies) {
if (dd.getAllExcludeRules().length > 0) {
return true;
}
@ -692,9 +685,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
* configurations existence and cycles are checked
*/
public void check() {
Stack confs = new Stack();
for (Iterator iter = configurations.values().iterator(); iter.hasNext();) {
Configuration conf = (Configuration) iter.next();
Stack<String> confs = new Stack<String>();
for (Configuration conf : configurations.values()) {
String[] ext = conf.getExtends();
for (int i = 0; i < ext.length; i++) {
confs.push(conf.getName());
@ -704,7 +696,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
}
private void checkConf(Stack confs, String confName) {
private void checkConf(Stack<String> confs, String confName) {
int index = confs.indexOf(confName);
if (index != -1) {
StringBuffer cycle = new StringBuffer();
@ -756,7 +748,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
return resolvedRevId.getAttribute(attName);
}
public Map getAttributes() {
public Map<String, String> getAttributes() {
return resolvedRevId.getAttributes();
}
@ -764,11 +756,11 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
return resolvedRevId.getExtraAttribute(attName);
}
public Map getExtraAttributes() {
public Map<String, String> getExtraAttributes() {
return resolvedRevId.getExtraAttributes();
}
public Map getQualifiedExtraAttributes() {
public Map<String, String> getQualifiedExtraAttributes() {
return resolvedRevId.getQualifiedExtraAttributes();
}
@ -807,26 +799,25 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
public ExcludeRule[] getAllExcludeRules() {
return (ExcludeRule[]) excludeRules.toArray(new ExcludeRule[excludeRules.size()]);
return excludeRules.toArray(new ExcludeRule[excludeRules.size()]);
}
public ExcludeRule[] getExcludeRules(String[] moduleConfigurations) {
Set rules = new LinkedHashSet();
for (Iterator iter = excludeRules.iterator(); iter.hasNext();) {
ExcludeRule rule = (ExcludeRule) iter.next();
Set<ExcludeRule> rules = new LinkedHashSet<ExcludeRule>();
for (ExcludeRule rule : excludeRules) {
String[] ruleConfs = rule.getConfigurations();
if (containsAny(ruleConfs, moduleConfigurations)) {
rules.add(rule);
}
}
return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
return rules.toArray(new ExcludeRule[rules.size()]);
}
private boolean containsAny(String[] arr1, String[] arr2) {
return new ArrayList(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
return new ArrayList<String>(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
}
public Map getExtraAttributesNamespaces() {
public Map<String, String> getExtraAttributesNamespaces() {
return extraAttributesNamespaces;
}

View File

@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.ivy.core.module.descriptor;
import java.util.Date;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
import org.apache.ivy.plugins.repository.Resource;
public class DefaultWorkspaceModuleDescriptor extends DefaultModuleDescriptor implements
WorkspaceModuleDescriptor {
public DefaultWorkspaceModuleDescriptor(ModuleDescriptorParser parser, Resource res) {
super(parser, res);
}
public DefaultWorkspaceModuleDescriptor(ModuleRevisionId id, String status, Date pubDate) {
super(id, status, pubDate);
}
public DefaultWorkspaceModuleDescriptor(ModuleRevisionId id, String status, Date pubDate,
boolean isDefault) {
super(id, status, pubDate, isDefault);
}
}

View File

@ -15,20 +15,12 @@
* limitations under the License.
*
*/
package org.apache.ivy.ant;
package org.apache.ivy.core.module.descriptor;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
/**
* Marker interface for module descriptor of a module in a workspace, then having special semantics,
* like artifacts declared by the resolver rather than the descriptor
*/
public interface WorkspaceModuleDescriptor extends ModuleDescriptor {
public class AntTestHelper {
// this is probably already available in some Ant class or helper...
public static Project newProject() {
Project project = new Project();
DefaultLogger logger = new DefaultLogger();
logger.setMessageOutputLevel(Project.MSG_INFO);
logger.setOutputPrintStream(System.out);
logger.setErrorPrintStream(System.out);
project.addBuildListener(logger);
return project;
}
}

View File

@ -19,7 +19,6 @@ package org.apache.ivy.core.module.id;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -56,13 +55,13 @@ import org.apache.ivy.plugins.matcher.PatternMatcher;
*/
public class MatcherLookup {
//private static final String FORMAT = "{org:%s, module:%s}";
// private static final String FORMAT = "{org:%s, module:%s}";
private static final String DEFAULT = "{org:" + "default" + ", module:" + "default" + "}";
private Map/* <String, List<MapMatcher>> */lookup = new HashMap();
private Map<String, List<MapMatcher>> lookup = new HashMap<String, List<MapMatcher>>();
private List/* <MapMatcher> */non_exact_matchers = new ArrayList();
private List<MapMatcher> non_exact_matchers = new ArrayList<MapMatcher>();
/**
* Add matcher.
@ -79,10 +78,10 @@ public class MatcherLookup {
non_exact_matchers.add(matcher);
return;
}
Object key = key(matcher.getAttributes());
List exact_matchers = (List) lookup.get(key);
String key = key(matcher.getAttributes());
List<MapMatcher> exact_matchers = lookup.get(key);
if (exact_matchers == null) {
exact_matchers = new ArrayList();
exact_matchers = new ArrayList<MapMatcher>();
lookup.put(key, exact_matchers);
}
exact_matchers.add(matcher);
@ -96,23 +95,21 @@ public class MatcherLookup {
*
* @return list A list of candidate matchers that matches specified attributes
*/
public List get(Map attrs) {
List matchers = new ArrayList();
public List<MapMatcher> get(Map<String, String> attrs) {
List<MapMatcher> matchers = new ArrayList<MapMatcher>();
// Step 1: find matchers from non_exact_matchers list
if (!non_exact_matchers.isEmpty()) {
for (Iterator iter = non_exact_matchers.iterator(); iter.hasNext();) {
MapMatcher matcher = (MapMatcher) iter.next();
for (MapMatcher matcher : non_exact_matchers) {
if (matcher.matches(attrs)) {
matchers.add(matcher);
}
}
}
// Step 2: find matchers from exact_matchers list of key
Object key = key(attrs);
List exact_matchers = (List) lookup.get(key);
String key = key(attrs);
List<MapMatcher> exact_matchers = lookup.get(key);
if (exact_matchers != null) {
for (Iterator iter = exact_matchers.iterator(); iter.hasNext();) {
MapMatcher matcher = (MapMatcher) iter.next();
for (MapMatcher matcher : exact_matchers) {
if (matcher.matches(attrs)) {
matchers.add(matcher);
}
@ -120,10 +117,9 @@ public class MatcherLookup {
}
// Step 3: (iff key != DEFAULT) find matchers from exact_matchers of DEFAULT
if (key != DEFAULT) {
List default_exact_matchers = (List) lookup.get(DEFAULT);
List<MapMatcher> default_exact_matchers = lookup.get(DEFAULT);
if (default_exact_matchers != null) {
for (Iterator iter = default_exact_matchers.iterator(); iter.hasNext();) {
MapMatcher matcher = (MapMatcher) iter.next();
for (MapMatcher matcher : default_exact_matchers) {
if (matcher.matches(attrs)) {
matchers.add(matcher);
}
@ -140,9 +136,9 @@ public class MatcherLookup {
* A map of attributes
* @return key object
*/
private Object key(Map attrs) {
Object org = attrs.get(IvyPatternHelper.ORGANISATION_KEY);
Object module = attrs.get(IvyPatternHelper.MODULE_KEY);
private String key(Map<String, String> attrs) {
String org = attrs.get(IvyPatternHelper.ORGANISATION_KEY);
String module = attrs.get(IvyPatternHelper.MODULE_KEY);
if (org == null || PatternMatcher.ANY_EXPRESSION.equals(org) || module == null
|| PatternMatcher.ANY_EXPRESSION.equals(module)) {
return DEFAULT;

View File

@ -31,10 +31,11 @@ import org.apache.ivy.core.IvyPatternHelper;
*
* @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
*/
public class ModuleId implements Comparable {
public class ModuleId implements Comparable<ModuleId> {
static final String ENCODE_SEPARATOR = ":#@#:";
private static final Map/* <ModuleId, WeakReference<ModuleId>> */CACHE = new WeakHashMap();
private static final Map<ModuleId, WeakReference<ModuleId>> CACHE = new WeakHashMap<ModuleId, WeakReference<ModuleId>>();
/**
* Returns a ModuleId for the given organization and module name.
@ -65,13 +66,13 @@ public class ModuleId implements Comparable {
ModuleId r = null;
synchronized (CACHE) {
WeakReference ref = (WeakReference) CACHE.get(moduleId);
WeakReference<ModuleId> ref = CACHE.get(moduleId);
if (ref != null) {
r = (ModuleId) ref.get();
r = ref.get();
}
if (r == null) {
r = moduleId;
CACHE.put(r, new WeakReference(r));
CACHE.put(r, new WeakReference<ModuleId>(r));
}
}
@ -84,7 +85,7 @@ public class ModuleId implements Comparable {
private int hash;
private Map/* <String, String> */attributes = new HashMap();
private Map<String, String> attributes = new HashMap<String, String>();
/**
* Constructor.
@ -122,7 +123,7 @@ public class ModuleId implements Comparable {
return organisation;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ModuleId)) {
return false;
@ -135,7 +136,7 @@ public class ModuleId implements Comparable {
}
}
/** {@inheritDoc} */
@Override
public int hashCode() {
if (hash == 0) {
// CheckStyle:MagicNumber| OFF
@ -147,14 +148,12 @@ public class ModuleId implements Comparable {
return hash;
}
/** {@inheritDoc} */
@Override
public String toString() {
return organisation + "#" + name;
}
/** {@inheritDoc} */
public int compareTo(Object obj) {
ModuleId that = (ModuleId) obj;
public int compareTo(ModuleId that) {
int result = organisation.compareTo(that.organisation);
if (result == 0) {
result = name.compareTo(that.name);
@ -177,7 +176,7 @@ public class ModuleId implements Comparable {
*
* @return A Map instance containing all the attributes and their values.
*/
public Map getAttributes() {
public Map<String, String> getAttributes() {
return attributes;
}

View File

@ -19,8 +19,8 @@ package org.apache.ivy.core.module.id;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.WeakHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -36,6 +36,7 @@ import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
* @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
*/
public class ModuleRevisionId extends UnmodifiableExtendableItem {
private static final String ENCODE_SEPARATOR = ModuleId.ENCODE_SEPARATOR;
private static final String ENCODE_PREFIX = "+";
@ -46,7 +47,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
private static final String REV_STRICT_CHARS_PATTERN = "[a-zA-Z0-9\\-/\\._+=,\\[\\]\\{\\}\\(\\):@]";
private static final Map/* <ModuleRevisionId, ModuleRevisionId> */CACHE = new WeakHashMap();
private static final Map<ModuleRevisionId, WeakReference<ModuleRevisionId>> CACHE = new WeakHashMap<ModuleRevisionId, WeakReference<ModuleRevisionId>>();
/**
* Pattern to use to matched mrid text representation.
@ -97,7 +98,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
}
public static ModuleRevisionId newInstance(String organisation, String name, String revision,
Map extraAttributes) {
Map<String, String> extraAttributes) {
return intern(new ModuleRevisionId(ModuleId.newInstance(organisation, name), revision,
extraAttributes));
}
@ -109,13 +110,14 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
}
public static ModuleRevisionId newInstance(String organisation, String name, String branch,
String revision, Map extraAttributes) {
String revision, Map<String, String> extraAttributes) {
return intern(new ModuleRevisionId(ModuleId.newInstance(organisation, name), branch,
revision, extraAttributes));
}
public static ModuleRevisionId newInstance(String organisation, String name, String branch,
String revision, Map extraAttributes, boolean replaceNullBranchWithDefault) {
String revision, Map<String, String> extraAttributes,
boolean replaceNullBranchWithDefault) {
return intern(new ModuleRevisionId(ModuleId.newInstance(organisation, name), branch,
revision, extraAttributes, replaceNullBranchWithDefault));
}
@ -149,13 +151,13 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
ModuleRevisionId r = null;
synchronized (CACHE) {
WeakReference ref = (WeakReference) CACHE.get(moduleRevisionId);
WeakReference<ModuleRevisionId> ref = CACHE.get(moduleRevisionId);
if (ref != null) {
r = (ModuleRevisionId) ref.get();
r = ref.get();
}
if (r == null) {
r = moduleRevisionId;
CACHE.put(r, new WeakReference(r));
CACHE.put(r, new WeakReference<ModuleRevisionId>(r));
}
}
@ -180,16 +182,17 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
this(moduleId, branch, revision, null);
}
private ModuleRevisionId(ModuleId moduleId, String revision, Map extraAttributes) {
private ModuleRevisionId(ModuleId moduleId, String revision, Map<String, String> extraAttributes) {
this(moduleId, null, revision, extraAttributes);
}
private ModuleRevisionId(ModuleId moduleId, String branch, String revision, Map extraAttributes) {
private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
Map<String, String> extraAttributes) {
this(moduleId, branch, revision, extraAttributes, true);
}
private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
Map extraAttributes, boolean replaceNullBranchWithDefault) {
Map<String, String> extraAttributes, boolean replaceNullBranchWithDefault) {
super(null, extraAttributes);
this.moduleId = moduleId;
IvyContext context = IvyContext.getContext();
@ -221,6 +224,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
return revision;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ModuleRevisionId)) {
return false;
@ -240,6 +244,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
}
}
@Override
public int hashCode() {
if (hash == 0) {
// CheckStyle:MagicNumber| OFF
@ -253,6 +258,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
return hash;
}
@Override
public String toString() {
return moduleId + (branch == null || branch.length() == 0 ? "" : "#" + branch) + ";"
+ (revision == null ? "NONE" : revision);
@ -260,13 +266,13 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
public String encodeToString() {
StringBuffer buf = new StringBuffer();
Map attributes = new HashMap(getAttributes());
Map<String, String> attributes = new HashMap<String, String>(getAttributes());
attributes.keySet().removeAll(getExtraAttributes().keySet());
attributes.putAll(getQualifiedExtraAttributes());
for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
String attName = (String) iter.next();
String value = (String) attributes.get(attName);
for (Entry<String, String> att : attributes.entrySet()) {
String attName = att.getKey();
String value = att.getValue();
value = value == null ? NULL_ENCODE : value;
buf.append(ENCODE_PREFIX).append(attName).append(ENCODE_SEPARATOR)
.append(ENCODE_PREFIX).append(value).append(ENCODE_SEPARATOR);
@ -280,7 +286,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ "'");
}
Map attributes = new HashMap();
Map<String, String> attributes = new HashMap<String, String>();
for (int i = 0; i < parts.length; i += 2) {
String attName = parts[i];
if (!attName.startsWith(ENCODE_PREFIX)) {
@ -301,10 +307,10 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
}
attributes.put(attName, attValue);
}
String org = (String) attributes.remove(IvyPatternHelper.ORGANISATION_KEY);
String mod = (String) attributes.remove(IvyPatternHelper.MODULE_KEY);
String rev = (String) attributes.remove(IvyPatternHelper.REVISION_KEY);
String branch = (String) attributes.remove(IvyPatternHelper.BRANCH_KEY);
String org = attributes.remove(IvyPatternHelper.ORGANISATION_KEY);
String mod = attributes.remove(IvyPatternHelper.MODULE_KEY);
String rev = attributes.remove(IvyPatternHelper.REVISION_KEY);
String branch = attributes.remove(IvyPatternHelper.BRANCH_KEY);
if (org == null) {
throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ "': no organisation");

View File

@ -19,10 +19,10 @@ package org.apache.ivy.core.module.id;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.plugins.matcher.MapMatcher;
import org.apache.ivy.util.Checks;
@ -49,8 +49,9 @@ import org.apache.ivy.util.filter.NoFilter;
* which resolver to use, which TTL in cache, ...)
* </p>
*/
public class ModuleRules {
private Map/* <MapMatcher,Object> */rules = new LinkedHashMap();
public class ModuleRules<T> {
private Map<MapMatcher, T> rules = new LinkedHashMap<MapMatcher, T>();
private MatcherLookup matcher_lookup = new MatcherLookup();
@ -60,10 +61,10 @@ public class ModuleRules {
public ModuleRules() {
}
private ModuleRules(Map/* <MapMatcher,Object> */rules) {
this.rules = new LinkedHashMap(rules);
for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
matcher_lookup.add((MapMatcher) iter.next());
private ModuleRules(Map<MapMatcher, T> rules) {
this.rules = new LinkedHashMap<MapMatcher, T>(rules);
for (MapMatcher matcher : rules.keySet()) {
matcher_lookup.add(matcher);
}
}
@ -75,7 +76,7 @@ public class ModuleRules {
* @param rule
* the rule to apply. Must not be <code>null</code>.
*/
public void defineRule(MapMatcher condition, Object rule) {
public void defineRule(MapMatcher condition, T rule) {
Checks.checkNotNull(condition, "condition");
Checks.checkNotNull(rule, "rule");
@ -93,8 +94,8 @@ public class ModuleRules {
* applies.
* @see #getRule(ModuleId, Filter)
*/
public Object getRule(ModuleId mid) {
return getRule(mid, NoFilter.INSTANCE);
public T getRule(ModuleId mid) {
return getRule(mid, NoFilter.<T> instance());
}
/**
@ -105,8 +106,8 @@ public class ModuleRules {
* the {@link ModuleId} to search the rule for. Must not be <code>null</code>.
* @return an array of rule objects matching the given {@link ModuleId}.
*/
public Object[] getRules(ModuleId mid) {
return getRules(mid.getAttributes(), NoFilter.INSTANCE);
public T[] getRules(ModuleId mid) {
return getRules(mid.getAttributes(), NoFilter.<T> instance());
}
/**
@ -120,8 +121,8 @@ public class ModuleRules {
* no rule applies.
* @see #getRule(ModuleRevisionId, Filter)
*/
public Object getRule(ModuleRevisionId mrid) {
return getRule(mrid, NoFilter.INSTANCE);
public T getRule(ModuleRevisionId mrid) {
return getRule(mrid, NoFilter.<T> instance());
}
/**
@ -140,7 +141,7 @@ public class ModuleRules {
* applies.
* @see #getRule(ModuleRevisionId, Filter)
*/
public Object getRule(ModuleId mid, Filter filter) {
public T getRule(ModuleId mid, Filter<T> filter) {
Checks.checkNotNull(mid, "mid");
return getRule(mid.getAttributes(), filter);
}
@ -161,18 +162,17 @@ public class ModuleRules {
* no rule applies.
* @see #getRule(ModuleRevisionId)
*/
public Object getRule(ModuleRevisionId mrid, Filter filter) {
public T getRule(ModuleRevisionId mrid, Filter<T> filter) {
Checks.checkNotNull(mrid, "mrid");
Checks.checkNotNull(filter, "filter");
Map moduleAttributes = mrid.getAttributes();
Map<String, String> moduleAttributes = mrid.getAttributes();
return getRule(moduleAttributes, filter);
}
private Object getRule(Map moduleAttributes, Filter filter) {
List matchers = matcher_lookup.get(moduleAttributes);
for (Iterator iter = matchers.iterator(); iter.hasNext();) {
MapMatcher midm = (MapMatcher) iter.next();
Object rule = rules.get(midm);
private T getRule(Map<String, String> moduleAttributes, Filter<T> filter) {
List<MapMatcher> matchers = matcher_lookup.get(moduleAttributes);
for (MapMatcher midm : matchers) {
T rule = rules.get(midm);
if (filter.accept(rule)) {
return rule;
}
@ -193,24 +193,23 @@ public class ModuleRules {
* {@link ModuleRevisionId}. Must not be <code>null</code>.
* @return an array of rule objects matching the given {@link ModuleRevisionId}.
*/
public Object[] getRules(ModuleRevisionId mrid, Filter filter) {
public T[] getRules(ModuleRevisionId mrid, Filter<T> filter) {
Checks.checkNotNull(mrid, "mrid");
Checks.checkNotNull(filter, "filter");
Map moduleAttributes = mrid.getAttributes();
Map<String, String> moduleAttributes = mrid.getAttributes();
return getRules(moduleAttributes, filter);
}
private Object[] getRules(Map moduleAttributes, Filter filter) {
List matchers = matcher_lookup.get(moduleAttributes);
List matchingRules = new ArrayList();
for (Iterator iter = matchers.iterator(); iter.hasNext();) {
MapMatcher midm = (MapMatcher) iter.next();
Object rule = rules.get(midm);
private T[] getRules(Map<String, String> moduleAttributes, Filter<T> filter) {
List<MapMatcher> matchers = matcher_lookup.get(moduleAttributes);
List<T> matchingRules = new ArrayList<T>();
for (MapMatcher midm : matchers) {
T rule = rules.get(midm);
if (filter.accept(rule)) {
matchingRules.add(rule);
}
}
return matchingRules.toArray();
return matchingRules.toArray((T[]) new Object[0]);
}
/**
@ -223,9 +222,9 @@ public class ModuleRules {
if (rules.isEmpty()) {
Message.debug(prefix + "NONE");
} else {
for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
MapMatcher midm = (MapMatcher) iter.next();
Object rule = rules.get(midm);
for (Entry<MapMatcher, T> entry : rules.entrySet()) {
MapMatcher midm = entry.getKey();
T rule = entry.getValue();
Message.debug(prefix + midm + " -> " + rule);
}
}
@ -240,11 +239,12 @@ public class ModuleRules {
*
* @return an unmodifiable view of all the rules defined on this ModuleRules.
*/
public Map/* <MapMatcher,Object> */getAllRules() {
public Map<MapMatcher, T> getAllRules() {
return Collections.unmodifiableMap(rules);
}
@Override
public Object clone() {
return new ModuleRules(rules);
return new ModuleRules<T>(rules);
}
}

View File

@ -42,14 +42,14 @@ public class StatusManager {
return IvyContext.getContext().getSettings().getStatusManager();
}
private List status = new ArrayList();
private List<Status> status = new ArrayList<Status>();
private String defaultStatus;
// for easier querying only
private Map statusPriorityMap;
private Map<String, Integer> statusPriorityMap;
private Map statusIntegrationMap;
private Map<String, Boolean> statusIntegrationMap;
private String deliveryStatusListString;
@ -71,7 +71,7 @@ public class StatusManager {
this.defaultStatus = defaultStatus;
}
public List getStatuses() {
public List<Status> getStatuses() {
return status;
}
@ -79,14 +79,14 @@ public class StatusManager {
if (status.isEmpty()) {
throw new IllegalStateException("badly configured statuses: no status found");
}
statusPriorityMap = new HashMap();
for (ListIterator iter = status.listIterator(); iter.hasNext();) {
Status status = (Status) iter.next();
statusPriorityMap = new HashMap<String, Integer>();
for (ListIterator<Status> iter = status.listIterator(); iter.hasNext();) {
Status status = iter.next();
statusPriorityMap.put(status.getName(), new Integer(iter.previousIndex()));
}
statusIntegrationMap = new HashMap();
for (Iterator iter = status.iterator(); iter.hasNext();) {
Status status = (Status) iter.next();
statusIntegrationMap = new HashMap<String, Boolean>();
for (Iterator<Status> iter = status.iterator(); iter.hasNext();) {
Status status = iter.next();
statusIntegrationMap.put(status.getName(), Boolean.valueOf(status.isIntegration()));
}
}
@ -125,8 +125,7 @@ public class StatusManager {
public String getDeliveryStatusListString() {
if (deliveryStatusListString == null) {
StringBuffer ret = new StringBuffer();
for (Iterator iter = status.iterator(); iter.hasNext();) {
Status status = (Status) iter.next();
for (Status status : this.status) {
if (!status.isIntegration()) {
ret.append(status.getName()).append(",");
}

View File

@ -71,14 +71,14 @@ public class PackagingManager implements IvySettingsAware {
return unpacked;
}
public void unpackArtifact(Artifact artifact, File localFile, File archiveFile)
public Artifact unpackArtifact(Artifact artifact, File localFile, File archiveFile)
throws IOException {
String packaging = artifact.getExtraAttribute("packaging");
if (packaging == null) {
// not declared as packed, nothing to do
return;
return null;
}
String ext = artifact.getExt();
String[] packings = packaging.split(",");
InputStream in = null;
try {
@ -94,6 +94,7 @@ public class PackagingManager implements IvySettingsAware {
+ packings[i] + "' in the streamed chain: " + packaging);
}
in = ((StreamPacking) packing).unpack(in);
ext = packing.getUnpackedExtension(ext);
}
ArchivePacking packing = settings.getPackingRegistry().get(packings[0]);
if (packing == null) {
@ -101,6 +102,7 @@ public class PackagingManager implements IvySettingsAware {
+ "' in the packing chain: " + packaging);
}
packing.unpack(in, archiveFile);
ext = packing.getUnpackedExtension(ext);
} finally {
if (in != null) {
try {
@ -110,6 +112,12 @@ public class PackagingManager implements IvySettingsAware {
}
}
}
final DefaultArtifact unpacked = new DefaultArtifact(artifact.getModuleRevisionId(),
artifact.getPublicationDate(), artifact.getName(),
artifact.getType() + "_unpacked", ext);
return unpacked;
}
}

View File

@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
@ -75,8 +74,9 @@ public class PublishEngine {
* the name, type, ext url and extra attributes of the artifacts are really used. Other methods
* can return null safely.
*/
public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern,
String resolverName, PublishOptions options) throws IOException {
public Collection<Artifact> publish(ModuleRevisionId mrid,
Collection<String> srcArtifactPattern, String resolverName, PublishOptions options)
throws IOException {
Message.info(":: publishing :: " + mrid.getModuleId());
Message.verbose("\tvalidate = " + options.isValidate());
long start = System.currentTimeMillis();
@ -111,7 +111,8 @@ public class PublishEngine {
tmp.deleteOnExit();
String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
Set confsToRemove = new HashSet(Arrays.asList(md.getConfigurationsNames()));
Set<String> confsToRemove = new HashSet<String>(Arrays.asList(md
.getConfigurationsNames()));
confsToRemove.removeAll(Arrays.asList(confs));
try {
@ -131,8 +132,7 @@ public class PublishEngine {
.setMerge(options.isMerge())
.setMergedDescriptor(md)
.setConfsToExclude(
(String[]) confsToRemove.toArray(new String[confsToRemove
.size()])));
confsToRemove.toArray(new String[confsToRemove.size()])));
ivyFile = tmp;
// we parse the new file to get updated module descriptor
md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@ -169,15 +169,15 @@ public class PublishEngine {
}
// collect all declared artifacts of this module
Collection missing = publish(md, srcArtifactPattern, resolver, options);
Collection<Artifact> missing = publish(md, srcArtifactPattern, resolver, options);
Message.verbose("\tpublish done (" + (System.currentTimeMillis() - start) + "ms)");
return missing;
}
public Collection publish(ModuleDescriptor md, Collection srcArtifactPattern,
public Collection<Artifact> publish(ModuleDescriptor md, Collection<String> srcArtifactPattern,
DependencyResolver resolver, PublishOptions options) throws IOException {
Collection missing = new ArrayList();
Set artifactsSet = new LinkedHashSet();
Collection<Artifact> missing = new ArrayList<Artifact>();
Set<Artifact> artifactsSet = new LinkedHashSet<Artifact>();
String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
for (int i = 0; i < confs.length; i++) {
@ -195,11 +195,9 @@ public class PublishEngine {
}
}
// now collects artifacts files
Map/* <Artifact,File> */artifactsFiles = new LinkedHashMap();
for (Iterator iter = artifactsSet.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact) iter.next();
for (Iterator iterator = srcArtifactPattern.iterator(); iterator.hasNext();) {
String pattern = (String) iterator.next();
Map<Artifact, File> artifactsFiles = new LinkedHashMap<Artifact, File>();
for (Artifact artifact : artifactsSet) {
for (String pattern : srcArtifactPattern) {
File artifactFile = settings.resolveFile(IvyPatternHelper.substitute(
settings.substitute(pattern), artifact));
if (artifactFile.exists()) {
@ -210,8 +208,7 @@ public class PublishEngine {
if (!artifactsFiles.containsKey(artifact)) {
StringBuffer sb = new StringBuffer();
sb.append("missing artifact " + artifact + ":\n");
for (Iterator iterator = srcArtifactPattern.iterator(); iterator.hasNext();) {
String pattern = (String) iterator.next();
for (String pattern : srcArtifactPattern) {
sb.append("\t"
+ settings.resolveFile(IvyPatternHelper.substitute(pattern, artifact))
+ " file does not exist\n");
@ -253,10 +250,9 @@ public class PublishEngine {
try {
resolver.beginPublishTransaction(md.getModuleRevisionId(), options.isOverwrite());
// for each declared published artifact in this descriptor, do:
for (Iterator iter = artifactsFiles.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Entry) iter.next();
Artifact artifact = (Artifact) entry.getKey();
File artifactFile = (File) entry.getValue();
for (Entry<Artifact, File> entry : artifactsFiles.entrySet()) {
Artifact artifact = entry.getKey();
File artifactFile = entry.getValue();
publish(artifact, artifactFile, resolver, options.isOverwrite());
}
resolver.commitPublishTransaction();

View File

@ -57,6 +57,8 @@ public class ArtifactDownloadReport {
private File unpackedLocalFile;
private Artifact unpackedArtifact;
public ArtifactDownloadReport(Artifact artifact) {
this.artifact = artifact;
}
@ -164,6 +166,14 @@ public class ArtifactDownloadReport {
return unpackedLocalFile;
}
public void setUnpackedArtifact(final Artifact unpackedArtifact) {
this.unpackedArtifact = unpackedArtifact;
}
public Artifact getUnpackedArtifact() {
return this.unpackedArtifact;
}
public int hashCode() {
final int prime = 31;
int result = 1;

View File

@ -23,18 +23,18 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.cache.ResolutionCacheManager;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@ -50,17 +50,16 @@ import org.apache.ivy.util.filter.Filter;
public class ResolveReport {
private ModuleDescriptor md;
/** String conf -> ConfigurationResolveReport report */
private Map confReports = new LinkedHashMap();
private Map<String, ConfigurationResolveReport> confReports = new LinkedHashMap<String, ConfigurationResolveReport>();
private List problemMessages = new ArrayList();
private List<String> problemMessages = new ArrayList<String>();
/**
* the list of all dependencies resolved, ordered from the more dependent to the less dependent
*/
private List/* <IvyNode> */dependencies = new ArrayList();
private List<IvyNode> dependencies = new ArrayList<IvyNode>();
private List/* <Artifact> */artifacts = new ArrayList();
private List<Artifact> artifacts = new ArrayList<Artifact>();
private long resolveTime;
@ -84,20 +83,20 @@ public class ResolveReport {
}
public ConfigurationResolveReport getConfigurationReport(String conf) {
return (ConfigurationResolveReport) confReports.get(conf);
return confReports.get(conf);
}
public String[] getConfigurations() {
return (String[]) confReports.keySet().toArray(new String[confReports.size()]);
return confReports.keySet().toArray(new String[confReports.size()]);
}
public boolean hasError() {
boolean hasError = false;
for (Iterator it = confReports.values().iterator(); it.hasNext() && !hasError;) {
ConfigurationResolveReport report = (ConfigurationResolveReport) it.next();
hasError |= report.hasError();
for (ConfigurationResolveReport report : confReports.values()) {
if (report.hasError()) {
return true;
}
}
return hasError;
return false;
}
public void output(ReportOutputter[] outputters, ResolutionCacheManager cacheMgr,
@ -112,21 +111,19 @@ public class ResolveReport {
}
public IvyNode[] getEvictedNodes() {
Collection all = new LinkedHashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
Collection<IvyNode> all = new LinkedHashSet<IvyNode>();
for (ConfigurationResolveReport report : confReports.values()) {
all.addAll(Arrays.asList(report.getEvictedNodes()));
}
return (IvyNode[]) all.toArray(new IvyNode[all.size()]);
return all.toArray(new IvyNode[all.size()]);
}
public IvyNode[] getUnresolvedDependencies() {
Collection all = new LinkedHashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
Collection<IvyNode> all = new LinkedHashSet<IvyNode>();
for (ConfigurationResolveReport report : confReports.values()) {
all.addAll(Arrays.asList(report.getUnresolvedDependencies()));
}
return (IvyNode[]) all.toArray(new IvyNode[all.size()]);
return all.toArray(new IvyNode[all.size()]);
}
/**
@ -164,36 +161,32 @@ public class ResolveReport {
*/
public ArtifactDownloadReport[] getArtifactsReports(DownloadStatus downloadStatus,
boolean withEvicted) {
Collection all = new LinkedHashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
Collection<ArtifactDownloadReport> all = new LinkedHashSet<ArtifactDownloadReport>();
for (ConfigurationResolveReport report : confReports.values()) {
ArtifactDownloadReport[] reports = report.getArtifactsReports(downloadStatus,
withEvicted);
all.addAll(Arrays.asList(reports));
}
return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
return all.toArray(new ArtifactDownloadReport[all.size()]);
}
public ArtifactDownloadReport[] getArtifactsReports(ModuleRevisionId mrid) {
Collection all = new LinkedHashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
Collection<ArtifactDownloadReport> all = new LinkedHashSet<ArtifactDownloadReport>();
for (ConfigurationResolveReport report : confReports.values()) {
all.addAll(Arrays.asList(report.getDownloadReports(mrid)));
}
return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
return all.toArray(new ArtifactDownloadReport[all.size()]);
}
public void checkIfChanged() {
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
for (ConfigurationResolveReport report : confReports.values()) {
report.checkIfChanged();
}
}
/** Can only be called if checkIfChanged has been called */
public boolean hasChanged() {
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
for (ConfigurationResolveReport report : confReports.values()) {
if (report.hasChanged()) {
return true;
}
@ -201,18 +194,17 @@ public class ResolveReport {
return false;
}
public void setProblemMessages(List problems) {
public void setProblemMessages(List<String> problems) {
problemMessages = problems;
}
public List getProblemMessages() {
public List<String> getProblemMessages() {
return problemMessages;
}
public List getAllProblemMessages() {
List ret = new ArrayList(problemMessages);
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport r = (ConfigurationResolveReport) iter.next();
public List<String> getAllProblemMessages() {
List<String> ret = new ArrayList<String>(problemMessages);
for (ConfigurationResolveReport r : confReports.values()) {
IvyNode[] unresolved = r.getUnresolvedDependencies();
for (int i = 0; i < unresolved.length; i++) {
String errMsg = unresolved[i].getProblemMessage();
@ -230,12 +222,11 @@ public class ResolveReport {
return ret;
}
public void setDependencies(List dependencies, Filter artifactFilter) {
public void setDependencies(List<IvyNode> dependencies, Filter<Artifact> artifactFilter) {
this.dependencies = dependencies;
// collect list of artifacts
artifacts = new ArrayList();
for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
IvyNode dependency = (IvyNode) iter.next();
artifacts = new ArrayList<Artifact>();
for (IvyNode dependency : dependencies) {
if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()) {
artifacts.addAll(Arrays.asList(dependency.getSelectedArtifacts(artifactFilter)));
}
@ -257,7 +248,7 @@ public class ResolveReport {
*
* @return The list of all dependencies.
*/
public List/* <IvyNode> */getDependencies() {
public List<IvyNode> getDependencies() {
return dependencies;
}
@ -267,7 +258,7 @@ public class ResolveReport {
*
* @return The list of all artifacts.
*/
public List/* <Artifact> */getArtifacts() {
public List<Artifact> getArtifacts() {
return artifacts;
}
@ -276,11 +267,10 @@ public class ResolveReport {
*
* @return a list of ModuleId
*/
public List getModuleIds() {
List ret = new ArrayList();
List sortedDependencies = new ArrayList(dependencies);
for (Iterator iter = sortedDependencies.iterator(); iter.hasNext();) {
IvyNode dependency = (IvyNode) iter.next();
public List<ModuleId> getModuleIds() {
List<ModuleId> ret = new ArrayList<ModuleId>();
List<IvyNode> sortedDependencies = new ArrayList<IvyNode>(dependencies);
for (IvyNode dependency : sortedDependencies) {
ModuleId mid = dependency.getResolvedId().getModuleId();
if (!ret.contains(mid)) {
ret.add(mid);
@ -371,6 +361,15 @@ public class ResolveReport {
public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings, List<ModuleId> midToKeep) {
DefaultModuleDescriptor fixedmd = new DefaultModuleDescriptor(md.getModuleRevisionId(),
md.getStatus(), new Date());
// copy namespaces
for (Entry<String, String> ns : md.getExtraAttributesNamespaces().entrySet()) {
fixedmd.addExtraAttributeNamespace(ns.getKey(), ns.getValue());
}
// copy info
fixedmd.setDescription(md.getDescription());
fixedmd.setHomePage(md.getHomePage());
fixedmd.getExtraInfos().addAll(md.getExtraInfos());
// copy configurations
@ -379,55 +378,38 @@ public class ResolveReport {
fixedmd.addConfiguration(new Configuration(conf));
}
if (midToKeep != null && !midToKeep.isEmpty()) {
// add dependency we want to keep from the original module descriptor
DependencyDescriptor[] deps = md.getDependencies();
for (int i = 0; i < deps.length; i++) {
if (midToKeep.contains(deps[i].getDependencyId())) {
DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
deps[i].getDependencyRevisionId(), true, false, false);
List<String> confs = Arrays.asList(deps[i].getModuleConfigurations());
if (confs.size() == 1 && confs.get(0).equals("*")) {
confs = resolvedConfs;
}
for (String conf : confs) {
String[] extendedConfs = getExtendingConfs(conf);
String[] depConfs = deps[i].getDependencyConfigurations(conf);
for (String extendedConf : extendedConfs) {
if (resolvedConfs.contains(extendedConf)) {
for (String depConf : depConfs) {
dep.addDependencyConfiguration(extendedConf, depConf);
}
}
}
}
fixedmd.addDependency(dep);
}
// copy artifacts
for (String conf : resolvedConfs) {
for (Artifact a : md.getArtifacts(conf)) {
fixedmd.addArtifact(conf, a);
}
}
// add resolved dependencies
for (int i = 0; i < dependencies.size(); i++) {
IvyNode node = (IvyNode) dependencies.get(i);
if (midToKeep != null && midToKeep.contains(node.getModuleId())) {
continue;
for (IvyNode dep : dependencies) {
ModuleRevisionId depMrid;
boolean force;
if (midToKeep != null && midToKeep.contains(dep.getModuleId())) {
depMrid = dep.getId();
force = false;
} else {
depMrid = dep.getResolvedId();
force = true;
}
String[] rootConfs = node.getRootModuleConfigurations();
for (int j = 0; j < rootConfs.length; j++) {
if (node.isEvicted(rootConfs[j])) {
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(fixedmd, depMrid,
force, false, false);
boolean evicted = true;
for (String rootConf : dep.getRootModuleConfigurations()) {
if (dep.isEvicted(rootConf)) {
continue;
}
if (node.getAllArtifacts().length == 0) {
// no artifact: it was probably useful transitively, hence it is useless here
break;
evicted = false;
for (String targetConf : dep.getConfigurations(rootConf)) {
dd.addDependencyConfiguration(rootConf, targetConf);
}
DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
node.getResolvedId(), true, false, false);
String[] targetConfs = node.getConfigurations(rootConfs[j]);
for (int k = 0; k < targetConfs.length; k++) {
dep.addDependencyConfiguration(rootConfs[j], targetConfs[k]);
}
fixedmd.addDependency(dep);
}
if (!evicted) {
fixedmd.addDependency(dd);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.ivy.core.resolve;
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;
@ -191,8 +192,7 @@ public class IvyNode implements Comparable<IvyNode> {
if (settings.getVersionMatcher().isDynamic(getId())
&& settings.getVersionMatcher().isDynamic(module.getId())) {
Message.error("impossible to resolve dynamic revision for " + getId()
+ ": check your configuration and "
+ "make sure revision is part of your pattern");
+ ": check your configuration and make sure revision is part of your pattern");
problem = new RuntimeException("impossible to resolve dynamic revision");
return false;
}
@ -254,13 +254,12 @@ public class IvyNode implements Comparable<IvyNode> {
if (hasProblem()) {
Message.debug("problem : " + problem.getMessage());
return false;
} else {
DependencyDescriptor dd = getDependencyDescriptor(parent);
if (dd != null) {
usage.addUsage(rootModuleConf, dd, parentConf);
}
return loaded;
}
DependencyDescriptor dd = getDependencyDescriptor(parent);
if (dd != null) {
usage.addUsage(rootModuleConf, dd, parentConf);
}
return loaded;
}
private void moveToRealNode(String rootModuleConf, IvyNode parent, String parentConf,
@ -320,7 +319,7 @@ public class IvyNode implements Comparable<IvyNode> {
* the configuration to load of this node
* @param requestedConf
* the actual node conf requested, possibly extending the <code>conf</code> one.
* @return
* @return {@link Collection} of {@link IvyNode}
*/
public Collection<IvyNode> getDependencies(String rootModuleConf, String conf,
String requestedConf) {
@ -331,8 +330,8 @@ public class IvyNode implements Comparable<IvyNode> {
DependencyDescriptor[] dds = md.getDependencies();
// it's important to respect order => LinkedHashMap
Map<ModuleRevisionId, IvyNode> dependencies = new LinkedHashMap<ModuleRevisionId, IvyNode>();
for (int i = 0; i < dds.length; i++) {
DependencyDescriptor dd = data.mediate(dds[i]);
for (DependencyDescriptor dependencyDescriptor : dds) {
DependencyDescriptor dd = data.mediate(dependencyDescriptor);
String[] dependencyConfigurations = dd.getDependencyConfigurations(conf, requestedConf);
if (dependencyConfigurations.length == 0) {
// no configuration of the dependency is required for current confs :
@ -416,9 +415,8 @@ public class IvyNode implements Comparable<IvyNode> {
return null;
}
return Boolean.valueOf(c.doesCallersExclude(rootModuleConf, artifact, callersStack));
} else {
return Boolean.FALSE;
}
return Boolean.FALSE;
}
public boolean hasConfigurationsToLoad() {
@ -438,23 +436,24 @@ public class IvyNode implements Comparable<IvyNode> {
if (md != null) {
String[] confs = getRealConfs(conf);
addRootModuleConfigurations(usage, rootModuleConf, confs);
for (int i = 0; i < confs.length; i++) {
Configuration c = md.getConfiguration(confs[i]);
for (String realConf : confs) {
Configuration c = md.getConfiguration(realConf);
if (c == null) {
confsToFetch.remove(conf);
if (isConfRequiredByMergedUsageOnly(rootModuleConf, conf)) {
Message.verbose("configuration required by evicted revision is not available in "
+ "selected revision. skipping " + conf + " in " + this);
} else if (!conf.equals(confs[i])) {
} else if (!conf.equals(realConf)) {
problem = new RuntimeException("configuration not found in " + this + ": '"
+ conf + "'. Missing configuration: '" + confs[i]
+ conf + "'. Missing configuration: '" + realConf
+ "'. It was required from " + parent + " " + parentConf);
} else {
problem = new RuntimeException("configuration not found in " + this + ": '"
+ confs[i] + "'. It was required from " + parent + " " + parentConf);
+ realConf + "'. It was required from " + parent + " " + parentConf);
}
return false;
} else if (shouldBePublic && !isRoot()
}
if (shouldBePublic && !isRoot()
&& c.getVisibility() != Configuration.Visibility.PUBLIC) {
confsToFetch.remove(conf);
if (isConfRequiredByMergedUsageOnly(rootModuleConf, conf)) {
@ -479,20 +478,12 @@ public class IvyNode implements Comparable<IvyNode> {
private String getDefaultConf(String conf) {
Matcher m = FALLBACK_CONF_PATTERN.matcher(conf);
if (m.matches()) {
return m.group(2);
} else {
return conf;
}
return m.matches() ? m.group(2) : conf;
}
private String getMainConf(String conf) {
Matcher m = FALLBACK_CONF_PATTERN.matcher(conf);
if (m.matches()) {
return m.group(1);
} else {
return null;
}
return m.matches() ? m.group(1) : null;
}
public void updateConfsToFetch(Collection<String> confs) {
@ -526,7 +517,7 @@ public class IvyNode implements Comparable<IvyNode> {
* returns the required configurations from the given node
*
* @param in
* @return
* @return array of configuration names
*/
public String[] getRequiredConfigurations(IvyNode in, String inConf) {
Collection<String> req = new LinkedHashSet<String>();
@ -534,7 +525,7 @@ public class IvyNode implements Comparable<IvyNode> {
for (IvyNodeUsage usage : mergedUsages.values()) {
addAllIfNotNull(req, usage.getRequiredConfigurations(in, inConf));
}
return req == null ? new String[0] : req.toArray(new String[req.size()]);
return req.toArray(new String[req.size()]);
}
private <T> void addAllIfNotNull(Collection<T> into, Collection<T> col) {
@ -546,7 +537,7 @@ public class IvyNode implements Comparable<IvyNode> {
/**
* returns all the current required configurations of the node
*
* @return
* @return array of configuration names
*/
public String[] getRequiredConfigurations() {
Collection<String> required = new ArrayList<String>(confsToFetch.size()
@ -574,7 +565,7 @@ public class IvyNode implements Comparable<IvyNode> {
* Returns the configurations of the dependency required in a given root module configuration.
*
* @param rootModuleConf
* @return
* @return array of configuration names
*/
public String[] getConfigurations(String rootModuleConf) {
Set<String> depConfs = new LinkedHashSet<String>();
@ -613,29 +604,23 @@ public class IvyNode implements Comparable<IvyNode> {
private void addRootModuleConfigurations(IvyNodeUsage usage, String rootModuleConf,
String[] dependencyConfs) {
Set<String> depConfs = usage.addAndGetConfigurations(rootModuleConf);
if (md != null) {
// add all given dependency configurations to the set + extended ones
for (int i = 0; i < dependencyConfs.length; i++) {
depConfs.add(dependencyConfs[i]);
Configuration conf = md.getConfiguration(dependencyConfs[i]);
for (String dependencyConf : dependencyConfs) {
Configuration conf = md.getConfiguration(dependencyConf);
if (conf != null) {
String[] exts = conf.getExtends();
// recursive add of extended
addRootModuleConfigurations(usage, rootModuleConf, exts);
addRootModuleConfigurations(usage, rootModuleConf, conf.getExtends());
}
}
} else {
for (int i = 0; i < dependencyConfs.length; i++) {
depConfs.add(dependencyConfs[i]);
}
}
Collections.addAll(usage.addAndGetConfigurations(rootModuleConf), dependencyConfs);
}
/**
* Returns the root module configurations in which this dependency is required
*
* @return
* @return array of configuration names
*/
public String[] getRootModuleConfigurations() {
Set<String> confs = getRootModuleConfigurationsSet();
@ -645,7 +630,7 @@ public class IvyNode implements Comparable<IvyNode> {
/**
* Returns the root module configurations in which this dependency is required
*
* @return
* @return {@link Set} of configuration names
*/
public Set<String> getRootModuleConfigurationsSet() {
Set<String> confs = new LinkedHashSet<String>();
@ -674,9 +659,10 @@ public class IvyNode implements Comparable<IvyNode> {
}
conf = defaultConf;
}
if (conf.startsWith("*")) {
if (conf.charAt(0) == '*') {
return resolveSpecialConfigurations(new String[] {conf});
} else if (conf.indexOf(',') != -1) {
}
if (conf.indexOf(',') != -1) {
String[] confs = conf.split(",");
for (int i = 0; i < confs.length; i++) {
confs[i] = confs[i].trim();
@ -705,8 +691,9 @@ public class IvyNode implements Comparable<IvyNode> {
}
if (path.contains(parent)) {
path.add(0, parent);
Message.verbose("circular dependency found while looking for the path for another one: "
+ "was looking for " + from + " as a caller of " + path.get(path.size() - 1));
Message.verbose(
"circular dependency found while looking for the path for another one: was looking for "
+ from + " as a caller of " + path.get(path.size() - 1));
return path;
}
path.add(0, parent);
@ -761,7 +748,7 @@ public class IvyNode implements Comparable<IvyNode> {
/**
* Returns all the artifacts of this dependency required in all the root module configurations
*
* @return
* @return array of {@link Artifact}s
*/
public Artifact[] getAllArtifacts() {
Set<Artifact> ret = new HashSet<Artifact>();
@ -776,7 +763,7 @@ public class IvyNode implements Comparable<IvyNode> {
* which the node is not evicted nor blacklisted
*
* @param artifactFilter
* @return
* @return array of {@link Artifact}s
*/
public Artifact[] getSelectedArtifacts(Filter<Artifact> artifactFilter) {
Collection<Artifact> ret = new HashSet<Artifact>();
@ -794,7 +781,7 @@ public class IvyNode implements Comparable<IvyNode> {
* in the given root module configuration
*
* @param rootModuleConf
* @return
* @return array of {@link Artifact}s
*/
public Artifact[] getArtifacts(String rootModuleConf) {
// first we look for the dependency configurations required
@ -807,7 +794,7 @@ public class IvyNode implements Comparable<IvyNode> {
if (md == null) {
throw new IllegalStateException(
"impossible to get artifacts when data has not been loaded. IvyNode = "
+ this.toString());
+ this);
}
Set<Artifact> artifacts = new HashSet<Artifact>(); // the set we fill before returning
@ -966,7 +953,7 @@ public class IvyNode implements Comparable<IvyNode> {
if (md == null) {
throw new IllegalStateException(
"impossible to get conflict manager when data has not been loaded. IvyNode = "
+ this.toString());
+ this);
}
ConflictManager cm = md.getConflictManager(mid);
return cm == null ? settings.getConflictManager(mid) : cm;
@ -1020,11 +1007,11 @@ public class IvyNode implements Comparable<IvyNode> {
public ModuleRevisionId getResolvedId() {
if (md != null && md.getResolvedModuleRevisionId().getRevision() != null) {
return md.getResolvedModuleRevisionId();
} else if (module != null) {
return module.getId();
} else {
return getId();
}
if (module != null) {
return module.getId();
}
return getId();
}
/**
@ -1039,9 +1026,8 @@ public class IvyNode implements Comparable<IvyNode> {
// /////////////////////////////////////////////////////////////////////////////
boolean canExclude(String rootModuleConf) {
Caller[] callers = getCallers(rootModuleConf);
for (int i = 0; i < callers.length; i++) {
if (callers[i].canExclude()) {
for (Caller caller : getCallers(rootModuleConf)) {
if (caller.canExclude()) {
return true;
}
}
@ -1250,10 +1236,8 @@ public class IvyNode implements Comparable<IvyNode> {
}
private void clearEvictionDataInAllCallers(String rootModuleConf, Stack<IvyNode> callerStack) {
IvyNode node = callerStack.peek();
Caller[] callers = node.getCallers(rootModuleConf);
for (int i = 0; i < callers.length; i++) {
IvyNode callerNode = findNode(callers[i].getModuleRevisionId());
for (Caller caller : callerStack.peek().getCallers(rootModuleConf)) {
IvyNode callerNode = findNode(caller.getModuleRevisionId());
if (callerNode != null) {
callerNode.eviction = new IvyNodeEviction(callerNode);
if (!callerStack.contains(callerNode)) {
@ -1291,9 +1275,8 @@ public class IvyNode implements Comparable<IvyNode> {
if (isRoot()) {
return false;
}
String[] rootModuleConfigurations = getRootModuleConfigurations();
for (int i = 0; i < rootModuleConfigurations.length; i++) {
if (!isBlacklisted(rootModuleConfigurations[i])) {
for (String rootModuleConfiguration : getRootModuleConfigurations()) {
if (!isBlacklisted(rootModuleConfiguration)) {
return false;
}
}

View File

@ -27,6 +27,7 @@ import java.util.Set;
import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.IncludeRule;
import org.apache.ivy.core.module.descriptor.WorkspaceModuleDescriptor;
/**
* Class collecting usage data for an IvyNode.
@ -219,6 +220,10 @@ public class IvyNodeUsage {
}
protected Set<DependencyArtifactDescriptor> getDependencyArtifactsSet(String rootModuleConf) {
if (node.getDescriptor() instanceof WorkspaceModuleDescriptor) {
// for a module in the "workspace" artifacts will be actually declared by the resolver
return null;
}
Collection<Depender> dependersInConf = dependers.get(rootModuleConf);
if (dependersInConf == null) {
return null;

View File

@ -37,7 +37,8 @@ import org.apache.ivy.util.Message;
public class ResolveData {
private ResolveEngine engine;
private Map visitData; // shared map of all visit data: Map (ModuleRevisionId -> VisitData)
// shared map of all visit data
private Map<ModuleRevisionId, VisitData> visitData;
private ConfigurationResolveReport report;
@ -55,16 +56,16 @@ public class ResolveData {
}
public ResolveData(ResolveEngine engine, ResolveOptions options) {
this(engine, options, null, new LinkedHashMap());
this(engine, options, null, new LinkedHashMap<ModuleRevisionId, VisitData>());
}
public ResolveData(ResolveEngine engine, ResolveOptions options,
ConfigurationResolveReport report) {
this(engine, options, report, new LinkedHashMap());
this(engine, options, report, new LinkedHashMap<ModuleRevisionId, VisitData>());
}
public ResolveData(ResolveEngine engine, ResolveOptions options,
ConfigurationResolveReport report, Map visitData) {
ConfigurationResolveReport report, Map<ModuleRevisionId, VisitData> visitData) {
this.engine = engine;
this.report = report;
this.visitData = visitData;
@ -80,30 +81,28 @@ public class ResolveData {
return visitData == null ? null : visitData.getNode();
}
public Collection getNodes() {
Collection nodes = new ArrayList();
for (Iterator iter = visitData.values().iterator(); iter.hasNext();) {
VisitData vdata = (VisitData) iter.next();
public Collection<IvyNode> getNodes() {
Collection<IvyNode> nodes = new ArrayList<IvyNode>();
for (VisitData vdata : visitData.values()) {
nodes.add(vdata.getNode());
}
return nodes;
}
public Collection getNodeIds() {
public Collection<ModuleRevisionId> getNodeIds() {
return visitData.keySet();
}
public VisitData getVisitData(ModuleRevisionId mrid) {
VisitData result = (VisitData) visitData.get(mrid);
VisitData result = visitData.get(mrid);
if (result == null) {
// search again, now ignore the missing extra attributes
for (Iterator it = visitData.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Entry) it.next();
ModuleRevisionId current = (ModuleRevisionId) entry.getKey();
for (Entry<ModuleRevisionId, VisitData> entry : visitData.entrySet()) {
ModuleRevisionId current = entry.getKey();
if (isSubMap(mrid.getAttributes(), current.getAttributes())) {
result = (VisitData) entry.getValue();
result = entry.getValue();
break;
}
}
@ -115,7 +114,7 @@ public class ResolveData {
/**
* Checks whether one map is a sub-map of the other.
*/
private static boolean isSubMap(Map map1, Map map2) {
private static <K, V> boolean isSubMap(Map<K, V> map1, Map<K, V> map2) {
int map1Size = map1.size();
int map2Size = map2.size();
@ -123,11 +122,10 @@ public class ResolveData {
return map1.equals(map2);
}
Map smallest = map1Size < map2Size ? map1 : map2;
Map largest = map1Size < map2Size ? map2 : map1;
Map<K, V> smallest = map1Size < map2Size ? map1 : map2;
Map<K, V> largest = map1Size < map2Size ? map2 : map1;
for (Iterator it = smallest.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Entry) it.next();
for (Entry<K, V> entry : smallest.entrySet()) {
if (!largest.containsKey(entry.getKey())) {
return false;
@ -258,9 +256,10 @@ public class ResolveData {
}
void blacklist(IvyNode node) {
for (Iterator iter = visitData.entrySet().iterator(); iter.hasNext();) {
Entry entry = (Entry) iter.next();
VisitData vdata = (VisitData) entry.getValue();
for (Iterator<Entry<ModuleRevisionId, VisitData>> iter = visitData.entrySet().iterator(); iter
.hasNext();) {
Entry<ModuleRevisionId, VisitData> entry = iter.next();
VisitData vdata = entry.getValue();
if (vdata.getNode() == node && !node.getResolvedId().equals(entry.getKey())) {
// this visit data was associated with the blacklisted node,
// we discard this association
@ -298,14 +297,13 @@ public class ResolveData {
VisitNode current = getCurrentVisitNode();
if (current != null) {
// mediating dd through dependers stack
List dependers = new ArrayList(current.getPath());
List<VisitNode> dependers = new ArrayList<VisitNode>(current.getPath());
// the returned path contains the currently visited node, we are only interested in
// the dependers, so we remove the currently visted node from the end
dependers.remove(dependers.size() - 1);
// we want to apply mediation going up in the dependers stack, not the opposite
Collections.reverse(dependers);
for (Iterator iterator = dependers.iterator(); iterator.hasNext();) {
VisitNode n = (VisitNode) iterator.next();
for (VisitNode n : dependers) {
ModuleDescriptor md = n.getDescriptor();
if (md != null) {
dd = md.mediate(dd);

View File

@ -29,10 +29,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@ -88,7 +86,7 @@ public class ResolveEngine {
private SortEngine sortEngine;
private Set fetchedSet = new HashSet();
private Set<String> fetchedSet = new HashSet<String>();
private DependencyResolver dictatorResolver;
@ -251,7 +249,7 @@ public class ResolveEngine {
.getResolvedModuleRevisionId());
Properties props = new Properties();
if (dependencies.length > 0) {
Map forcedRevisions = new HashMap();
Map<ModuleId, ModuleRevisionId> forcedRevisions = new HashMap<ModuleId, ModuleRevisionId>();
for (int i = 0; i < dependencies.length; i++) {
if (dependencies[i].getModuleRevision() != null
&& dependencies[i].getModuleRevision().isForce()) {
@ -262,8 +260,7 @@ public class ResolveEngine {
IvyNode root = dependencies[0].getRoot();
// <ModuleId,IvyNode>();
Map topLevelDeps = new HashMap(); //
Map<ModuleId, IvyNode> topLevelDeps = new HashMap<ModuleId, IvyNode>();
for (int i = 0; i < dependencies.length; i++) {
if (!dependencies[i].hasProblem()) {
DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
@ -279,7 +276,7 @@ public class ResolveEngine {
DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
if (dd == null) {
ModuleId mid = dependencies[i].getModuleId();
IvyNode tlDep = (IvyNode) topLevelDeps.get(mid);
IvyNode tlDep = topLevelDeps.get(mid);
if (tlDep != null) {
dd = tlDep.getDependencyDescriptor(root);
}
@ -288,8 +285,8 @@ public class ResolveEngine {
ModuleRevisionId depResolvedId = dependencies[i].getResolvedId();
ModuleDescriptor depDescriptor = dependencies[i].getDescriptor();
ModuleRevisionId depRevisionId = dd.getDependencyRevisionId();
ModuleRevisionId forcedRevisionId = (ModuleRevisionId) forcedRevisions
.get(dependencies[i].getModuleId());
ModuleRevisionId forcedRevisionId = forcedRevisions.get(dependencies[i]
.getModuleId());
if (dependencies[i].getModuleRevision() != null
&& dependencies[i].getModuleRevision().isForce()
@ -373,14 +370,14 @@ public class ResolveEngine {
report.output(settings.getReportOutputters(), cacheMgr, options);
}
public void downloadArtifacts(ResolveReport report, Filter artifactFilter,
public void downloadArtifacts(ResolveReport report, Filter<Artifact> artifactFilter,
DownloadOptions options) {
long start = System.currentTimeMillis();
IvyNode[] dependencies = (IvyNode[]) report.getDependencies().toArray(
IvyNode[] dependencies = report.getDependencies().toArray(
new IvyNode[report.getDependencies().size()]);
eventManager.fireIvyEvent(new PrepareDownloadEvent((Artifact[]) report.getArtifacts()
.toArray(new Artifact[report.getArtifacts().size()])));
eventManager.fireIvyEvent(new PrepareDownloadEvent(report.getArtifacts().toArray(
new Artifact[report.getArtifacts().size()])));
long totalSize = 0;
for (int i = 0; i < dependencies.length; i++) {
@ -541,7 +538,7 @@ public class ResolveEngine {
throw new NullPointerException("module descriptor must not be null");
}
String[] confs = options.getConfs(md);
Collection missingConfs = new ArrayList();
Collection<String> missingConfs = new ArrayList<String>();
for (int i = 0; i < confs.length; i++) {
if (confs[i] == null) {
throw new NullPointerException("null conf not allowed: confs where: "
@ -608,41 +605,39 @@ public class ResolveEngine {
}
// clean data
for (Iterator iter = data.getNodes().iterator(); iter.hasNext();) {
IvyNode dep = (IvyNode) iter.next();
for (IvyNode dep : data.getNodes()) {
dep.clean();
}
}
// prune and reverse sort fectched dependencies
Collection nodes = data.getNodes();
Collection<IvyNode> nodes = data.getNodes();
// use a Set to avoid duplicates, linked to preserve order
Collection dependencies = new LinkedHashSet(nodes.size());
for (Iterator iter = nodes.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
Collection<IvyNode> dependencies = new LinkedHashSet<IvyNode>(nodes.size());
for (IvyNode node : nodes) {
if (node != null && !node.isRoot() && !node.isCompletelyBlacklisted()) {
dependencies.add(node);
}
}
List sortedDependencies = sortEngine.sortNodes(dependencies, SortOptions.SILENT);
List<IvyNode> sortedDependencies = sortEngine.sortNodes(dependencies,
SortOptions.SILENT);
Collections.reverse(sortedDependencies);
handleTransiviteEviction(md, confs, data, sortedDependencies);
return (IvyNode[]) dependencies.toArray(new IvyNode[dependencies.size()]);
return dependencies.toArray(new IvyNode[dependencies.size()]);
} finally {
IvyContext.popContext();
}
}
private void handleTransiviteEviction(ModuleDescriptor md, String[] confs, ResolveData data,
List sortedDependencies) {
List<IvyNode> sortedDependencies) {
// handle transitive eviction now:
// if a module has been evicted then all its dependencies required only by it should be
// evicted too. Since nodes are now sorted from the more dependent to the less one, we
// can traverse the list and check only the direct parent and not all the ancestors
for (ListIterator iter = sortedDependencies.listIterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
for (IvyNode node : sortedDependencies) {
if (!node.isCompletelyEvicted()) {
for (int i = 0; i < confs.length; i++) {
IvyNodeCallers.Caller[] callers = node.getCallers(confs[i]);
@ -740,8 +735,7 @@ public class ResolveEngine {
// update selected nodes with confs asked in evicted one
EvictionData ed = node.getEvictedData();
if (ed.getSelected() != null) {
for (Iterator iter = ed.getSelected().iterator(); iter.hasNext();) {
IvyNode selected = (IvyNode) iter.next();
for (IvyNode selected : ed.getSelected()) {
if (!selected.isLoaded()) {
// the node is not yet loaded, we can simply update its set of
// configurations to fetch
@ -793,9 +787,8 @@ public class ResolveEngine {
// now we can actually resolve this configuration dependencies
if (!isDependenciesFetched(node.getNode(), conf) && node.isTransitive()) {
Collection/* <VisitNode> */dependencies = node.getDependencies(conf);
for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
VisitNode dep = (VisitNode) iter.next();
Collection<VisitNode> dependencies = node.getDependencies(conf);
for (VisitNode dep : dependencies) {
dep.useRealNode(); // the node may have been resolved to another real one while
// resolving other deps
String[] confs = dep.getRequiredConfigurations(node, conf);
@ -853,7 +846,7 @@ public class ResolveEngine {
}
private void resolveConflict(VisitNode node, String conf) {
resolveConflict(node, node.getParent(), conf, Collections.EMPTY_SET);
resolveConflict(node, node.getParent(), conf, Collections.<IvyNode> emptySet());
}
/**
@ -870,7 +863,7 @@ public class ResolveEngine {
* @return true if conflict resolution has been done, false it can't be done yet
*/
private boolean resolveConflict(VisitNode node, VisitNode ancestor, String conf,
Collection toevict) {
Collection<IvyNode> toevict) {
if (ancestor == null || node == ancestor) {
return true;
}
@ -907,15 +900,16 @@ public class ResolveEngine {
}
// compute conflicts
Set resolvedNodes = ancestor.getNode().getResolvedNodes(node.getModuleId(),
Set<IvyNode> resolvedNodes = ancestor.getNode().getResolvedNodes(node.getModuleId(),
node.getRootModuleConf());
resolvedNodes.addAll(ancestor.getNode().getPendingConflicts(node.getRootModuleConf(),
node.getModuleId()));
Collection conflicts = computeConflicts(node, ancestor, conf, toevict, resolvedNodes);
Collection<IvyNode> conflicts = computeConflicts(node, ancestor, conf, toevict,
resolvedNodes);
ConflictManager conflictManager = ancestor.getNode().getConflictManager(node.getModuleId());
Collection resolved = resolveConflicts(node, ancestor, conflicts, conflictManager);
Collection<IvyNode> resolved = resolveConflicts(node, ancestor, conflicts, conflictManager);
if (resolved == null) {
if (debugConflictResolution) {
@ -939,8 +933,7 @@ public class ResolveEngine {
toevict = resolvedNodes;
toevict.removeAll(resolved);
for (Iterator iter = toevict.iterator(); iter.hasNext();) {
IvyNode te = (IvyNode) iter.next();
for (IvyNode te : toevict) {
te.markEvicted(node.getRootModuleConf(), ancestor.getNode(), conflictManager,
resolved);
@ -956,14 +949,14 @@ public class ResolveEngine {
ancestor.getNode().setResolvedNodes(node.getModuleId(), node.getRootModuleConf(),
resolved);
Collection evicted = new HashSet(ancestor.getNode().getEvictedNodes(node.getModuleId(),
node.getRootModuleConf()));
Collection<IvyNode> evicted = new HashSet<IvyNode>(ancestor.getNode().getEvictedNodes(
node.getModuleId(), node.getRootModuleConf()));
evicted.removeAll(resolved);
evicted.addAll(toevict);
ancestor.getNode().setEvictedNodes(node.getModuleId(), node.getRootModuleConf(),
evicted);
ancestor.getNode().setPendingConflicts(node.getModuleId(), node.getRootModuleConf(),
Collections.EMPTY_SET);
Collections.<IvyNode> emptySet());
return resolveConflict(node, ancestor.getParent(), conf, toevict);
} else {
@ -977,8 +970,8 @@ public class ResolveEngine {
// it's time to update parent resolved and evicted with what was found
Collection evicted = new HashSet(ancestor.getNode().getEvictedNodes(node.getModuleId(),
node.getRootModuleConf()));
Collection<IvyNode> evicted = new HashSet<IvyNode>(ancestor.getNode().getEvictedNodes(
node.getModuleId(), node.getRootModuleConf()));
toevict.removeAll(resolved);
evicted.removeAll(resolved);
evicted.addAll(toevict);
@ -986,7 +979,7 @@ public class ResolveEngine {
ancestor.getNode().setEvictedNodes(node.getModuleId(), node.getRootModuleConf(),
evicted);
ancestor.getNode().setPendingConflicts(node.getModuleId(), node.getRootModuleConf(),
Collections.EMPTY_SET);
Collections.<IvyNode> emptySet());
node.markEvicted(ancestor, conflictManager, resolved);
if (debugConflictResolution) {
@ -994,14 +987,13 @@ public class ResolveEngine {
}
// if resolved changed we have to go up in the graph
Collection prevResolved = ancestor.getNode().getResolvedNodes(node.getModuleId(),
node.getRootModuleConf());
Collection<IvyNode> prevResolved = ancestor.getNode().getResolvedNodes(
node.getModuleId(), node.getRootModuleConf());
boolean solved = true;
if (!prevResolved.equals(resolved)) {
ancestor.getNode().setResolvedNodes(node.getModuleId(), node.getRootModuleConf(),
resolved);
for (Iterator iter = resolved.iterator(); iter.hasNext();) {
IvyNode sel = (IvyNode) iter.next();
for (IvyNode sel : resolved) {
if (!prevResolved.contains(sel)) {
solved &= resolveConflict(node.gotoNode(sel), ancestor.getParent(), conf,
toevict);
@ -1012,8 +1004,8 @@ public class ResolveEngine {
}
}
private Collection resolveConflicts(VisitNode node, VisitNode ancestor, Collection conflicts,
ConflictManager conflictManager) {
private Collection<IvyNode> resolveConflicts(VisitNode node, VisitNode ancestor,
Collection<IvyNode> conflicts, ConflictManager conflictManager) {
if (node.getParent() != ancestor
// we are not handling the direct parent
@ -1064,9 +1056,9 @@ public class ResolveEngine {
* @return a collection of IvyNode which may be in conflict with the given node in the given
* ancestor. This collection always contain at least the given node.
*/
private Collection computeConflicts(VisitNode node, VisitNode ancestor, String conf,
Collection toevict, Collection selectedNodes) {
Collection conflicts = new LinkedHashSet();
private Collection<IvyNode> computeConflicts(VisitNode node, VisitNode ancestor, String conf,
Collection<IvyNode> toevict, Collection<IvyNode> selectedNodes) {
Collection<IvyNode> conflicts = new LinkedHashSet<IvyNode>();
conflicts.add(node.getNode());
/*
* We first try to remove all evicted nodes from the collection of selected nodes to update
@ -1087,11 +1079,11 @@ public class ResolveEngine {
data.setCurrentVisitNode(ancestor);
try {
// In this case we need to compute selected nodes again.
Collection deps = ancestor.getNode().getDependencies(node.getRootModuleConf(),
Collection<IvyNode> deps = ancestor.getNode().getDependencies(
node.getRootModuleConf(),
ancestor.getNode().getConfigurations(node.getRootModuleConf()),
ancestor.getRequestedConf());
for (Iterator iter = deps.iterator(); iter.hasNext();) {
IvyNode dep = (IvyNode) iter.next();
for (IvyNode dep : deps) {
if (dep.getModuleId().equals(node.getModuleId())) {
conflicts.add(dep);
}
@ -1108,12 +1100,11 @@ public class ResolveEngine {
* the parent direct dependencies in current root module conf.
*/
VisitNode parent = node.getParent();
Collection parentDepIvyNodes = parent.getNode().getDependencies(
Collection<IvyNode> parentDepIvyNodes = parent.getNode().getDependencies(
node.getRootModuleConf(),
parent.getNode().getConfigurations(node.getRootModuleConf()),
parent.getRequestedConf());
for (Iterator it = parentDepIvyNodes.iterator(); it.hasNext();) {
IvyNode parentDep = (IvyNode) it.next();
for (IvyNode parentDep : parentDepIvyNodes) {
if (parentDep.getModuleId().equals(node.getModuleId())) {
conflicts.add(parentDep);
}

View File

@ -20,6 +20,7 @@ package org.apache.ivy.core.resolve;
import java.util.Date;
import org.apache.ivy.core.LogOptions;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.util.ConfigurationUtils;
@ -100,7 +101,7 @@ public class ResolveOptions extends LogOptions {
/**
* A filter to use to avoid downloading all artifacts.
*/
private Filter artifactFilter = FilterHelper.NO_FILTER;
private Filter<Artifact> artifactFilter = FilterHelper.NO_FILTER;
/**
* The resolve mode to use. Should be one of {@link #RESOLVEMODES}, or <code>null</code> to use
@ -140,11 +141,11 @@ public class ResolveOptions extends LogOptions {
checkIfChanged = options.checkIfChanged;
}
public Filter getArtifactFilter() {
public Filter<Artifact> getArtifactFilter() {
return artifactFilter;
}
public ResolveOptions setArtifactFilter(Filter artifactFilter) {
public ResolveOptions setArtifactFilter(Filter<Artifact> artifactFilter) {
this.artifactFilter = artifactFilter;
return this;
}

View File

@ -38,7 +38,7 @@ public class VisitData {
* The associated visit nodes, per rootModuleConf Note that the value is a List, because a node
* can be visited from several parents during the resolution process
*/
private Map visitNodes = new HashMap(); // Map (String rootModuleConf -> List(VisitNode))
private Map<String, List<VisitNode>> visitNodes = new HashMap<String, List<VisitNode>>();
public VisitData(IvyNode node) {
this.node = node;
@ -49,10 +49,10 @@ public class VisitData {
getVisitNodes(rootModuleConf).add(node);
}
public List getVisitNodes(String rootModuleConf) {
List visits = (List) visitNodes.get(rootModuleConf);
public List<VisitNode> getVisitNodes(String rootModuleConf) {
List<VisitNode> visits = visitNodes.get(rootModuleConf);
if (visits == null) {
visits = new ArrayList();
visits = new ArrayList<VisitNode>();
visitNodes.put(rootModuleConf, visits);
}
return visits;
@ -66,7 +66,7 @@ public class VisitData {
this.node = node;
}
public void addVisitNodes(String rootModuleConf, List visitNodes) {
public void addVisitNodes(String rootModuleConf, List<VisitNode> visitNodes) {
getVisitNodes(rootModuleConf).addAll(visitNodes);
}
}

View File

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@ -70,7 +69,7 @@ public class VisitNode {
* Direct path from root to this node. Note that the colleciton is ordered but is not a list
* implementation This collection is null until it is required, see getPath
*/
private Collection path = null; // Collection(VisitNode)
private Collection<VisitNode> path = null;
/**
* The configuration of the parent module in the current visit
@ -159,16 +158,16 @@ public class VisitNode {
*
* @return
*/
public Collection/* <VisitNode> */getPath() {
public Collection<VisitNode> getPath() {
if (path == null) {
path = computePath();
}
return path;
}
private Collection/* <VisitNode> */computePath() {
private Collection<VisitNode> computePath() {
if (parent != null) {
Collection p = new LinkedHashSet(parent.getPath());
Collection<VisitNode> p = new LinkedHashSet<VisitNode>(parent.getPath());
p.add(this);
return p;
} else {
@ -200,7 +199,7 @@ public class VisitNode {
public static VisitNode getRoot(VisitNode parent) {
VisitNode root = parent;
Collection path = new HashSet();
Collection<VisitNode> path = new HashSet<VisitNode>();
path.add(root);
while (root.getParent() != null && !root.getNode().isRoot()) {
if (path.contains(root.getParent())) {
@ -309,11 +308,10 @@ public class VisitNode {
return loaded;
}
public Collection/* <VisitNode> */getDependencies(String conf) {
Collection/* <IvyNode> */deps = node.getDependencies(rootModuleConf, conf, requestedConf);
Collection/* <VisitNode> */ret = new ArrayList(deps.size());
for (Iterator iter = deps.iterator(); iter.hasNext();) {
IvyNode depNode = (IvyNode) iter.next();
public Collection<VisitNode> getDependencies(String conf) {
Collection<IvyNode> deps = node.getDependencies(rootModuleConf, conf, requestedConf);
Collection<VisitNode> ret = new ArrayList<VisitNode>(deps.size());
for (IvyNode depNode : deps) {
ret.add(traverseChild(conf, depNode));
}
return ret;
@ -336,9 +334,8 @@ public class VisitNode {
}
VisitData visitData = data.getVisitData(node.getId());
if (visitData != null) {
List visitNodes = visitData.getVisitNodes(rootModuleConf);
for (Iterator iter = visitNodes.iterator(); iter.hasNext();) {
VisitNode vnode = (VisitNode) iter.next();
List<VisitNode> visitNodes = visitData.getVisitNodes(rootModuleConf);
for (VisitNode vnode : visitNodes) {
if ((parent == null && vnode.getParent() == null)
|| (parent != null && parent.getId().equals(vnode.getParent().getId()))) {
vnode.parentConf = parentConf;
@ -371,11 +368,10 @@ public class VisitNode {
return new VisitNode(data, node, parent, rootModuleConf, parentConf, usage);
}
private ModuleRevisionId[] toMrids(Collection path, ModuleRevisionId last) {
private ModuleRevisionId[] toMrids(Collection<VisitNode> path, ModuleRevisionId last) {
ModuleRevisionId[] ret = new ModuleRevisionId[path.size() + 1];
int i = 0;
for (Iterator iter = path.iterator(); iter.hasNext(); i++) {
VisitNode node = (VisitNode) iter.next();
for (VisitNode node : path) {
ret[i] = node.getNode().getId();
}
ret[ret.length - 1] = last;
@ -386,7 +382,7 @@ public class VisitNode {
return node.getResolvedId();
}
public void updateConfsToFetch(Collection confs) {
public void updateConfsToFetch(Collection<String> confs) {
node.updateConfsToFetch(confs);
}
@ -432,8 +428,7 @@ public class VisitNode {
if (parent != null) {
isCircular = Boolean.FALSE; // asumme it's false, and see if it isn't by checking
// the parent path
for (Iterator iter = parent.getPath().iterator(); iter.hasNext();) {
VisitNode ancestor = (VisitNode) iter.next();
for (VisitNode ancestor : parent.getPath()) {
if (getId().getModuleId().equals(ancestor.getId().getModuleId())) {
isCircular = Boolean.TRUE;
break;
@ -458,7 +453,7 @@ public class VisitNode {
return node.getModuleId();
}
public Collection getResolvedRevisions(ModuleId mid) {
public Collection<ModuleRevisionId> getResolvedRevisions(ModuleId mid) {
return node.getResolvedRevisions(mid, rootModuleConf);
}
@ -481,7 +476,8 @@ public class VisitNode {
* @param selected
* a Collection of {@link IvyNode} which have been selected
*/
public void markEvicted(VisitNode parent, ConflictManager conflictMgr, Collection selected) {
public void markEvicted(VisitNode parent, ConflictManager conflictMgr,
Collection<IvyNode> selected) {
node.markEvicted(rootModuleConf, parent.getNode(), conflictMgr, selected);
}
@ -493,7 +489,7 @@ public class VisitNode {
return node.getEvictionDataInRoot(rootModuleConf, ancestor.getNode());
}
public Collection getEvictedRevisions(ModuleId moduleId) {
public Collection<ModuleRevisionId> getEvictedRevisions(ModuleId moduleId) {
return node.getEvictedRevisions(moduleId, rootModuleConf);
}
@ -508,6 +504,7 @@ public class VisitNode {
// rootModuleConf = rootModuleConf;
// }
@Override
public String toString() {
return node.toString();
}

View File

@ -46,6 +46,7 @@ import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ArtifactRevisionId;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.pack.PackagingManager;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.resolve.ResolveOptions;
import org.apache.ivy.plugins.report.XmlReportParser;
@ -331,12 +332,29 @@ public class RetrieveEngine {
artifacts.add(parser.getMetadataArtifactReport(mrids[j]));
}
}
for (ArtifactDownloadReport adr : artifacts) {
final PackagingManager packagingManager = new PackagingManager();
packagingManager.setSettings(IvyContext.getContext().getSettings());
Artifact artifact = adr.getArtifact();
String ext = artifact.getExt();
if (adr.getUnpackedLocalFile() != null) {
ext = "";
for (final ArtifactDownloadReport adr : artifacts) {
final Artifact artifact = adr.getArtifact();
final String ext;
if (adr.getUnpackedLocalFile() == null) {
ext = artifact.getExt();
} else {
final Artifact unpackedArtifact;
// check if the download report is aware of the unpacked artifact
if (adr.getUnpackedArtifact() != null) {
unpackedArtifact = adr.getUnpackedArtifact();
} else {
// use the packaging manager to get hold of the unpacked artifact
unpackedArtifact = packagingManager.getUnpackedArtifact(artifact);
}
if (unpackedArtifact == null) {
throw new RuntimeException("Could not determine unpacked artifact for " + artifact +
" while determining artifacts to copy for module " + mrid);
}
ext = unpackedArtifact.getExt();
}
String destPattern = "ivy".equals(adr.getType()) ? destIvyPattern : destFilePattern;

View File

@ -22,7 +22,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@ -56,125 +55,119 @@ public class SearchEngine {
* @param otherTokenValues
* @return
*/
public String[] listTokenValues(String token, Map otherTokenValues) {
Set entries = new LinkedHashSet();
public String[] listTokenValues(String token, Map<String, Object> otherTokenValues) {
Set<String> entries = new LinkedHashSet<String>();
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] values = resolver.listTokenValues(new String[] {token}, otherTokenValues);
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] values = resolver.listTokenValues(new String[] {token},
otherTokenValues);
for (int i = 0; i < values.length; i++) {
entries.add(values[i].get(token));
}
}
return (String[]) entries.toArray(new String[entries.size()]);
return entries.toArray(new String[entries.size()]);
}
public OrganisationEntry[] listOrganisationEntries() {
Set entries = new HashSet();
Set<OrganisationEntry> entries = new HashSet<OrganisationEntry>();
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] orgs = resolver.listTokenValues(new String[] {IvyPatternHelper.ORGANISATION_KEY},
new HashMap());
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] orgs = resolver.listTokenValues(
new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap<String, Object>());
for (int i = 0; i < orgs.length; i++) {
String org = (String) orgs[i].get(IvyPatternHelper.ORGANISATION_KEY);
String org = orgs[i].get(IvyPatternHelper.ORGANISATION_KEY);
entries.add(new OrganisationEntry(resolver, org));
}
}
return (OrganisationEntry[]) entries.toArray(new OrganisationEntry[entries.size()]);
return entries.toArray(new OrganisationEntry[entries.size()]);
}
public String[] listOrganisations() {
Set entries = new HashSet();
Set<String> entries = new HashSet<String>();
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] orgs = resolver.listTokenValues(new String[] {IvyPatternHelper.ORGANISATION_KEY},
new HashMap());
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] orgs = resolver.listTokenValues(
new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap<String, Object>());
for (int i = 0; i < orgs.length; i++) {
entries.add(orgs[i].get(IvyPatternHelper.ORGANISATION_KEY));
}
}
return (String[]) entries.toArray(new String[entries.size()]);
return entries.toArray(new String[entries.size()]);
}
public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
Set entries = new HashSet();
Set<ModuleEntry> entries = new HashSet<ModuleEntry>();
Map tokenValues = new HashMap();
Map<String, Object> tokenValues = new HashMap<String, Object>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] modules = resolver.listTokenValues(new String[] {IvyPatternHelper.MODULE_KEY},
tokenValues);
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] modules = resolver.listTokenValues(
new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
for (int i = 0; i < modules.length; i++) {
String module = (String) modules[i].get(IvyPatternHelper.MODULE_KEY);
String module = modules[i].get(IvyPatternHelper.MODULE_KEY);
entries.add(new ModuleEntry(org, module));
}
}
return (ModuleEntry[]) entries.toArray(new ModuleEntry[entries.size()]);
return entries.toArray(new ModuleEntry[entries.size()]);
}
public String[] listModules(String org) {
Set entries = new HashSet();
Set<String> entries = new HashSet<String>();
Map tokenValues = new HashMap();
Map<String, Object> tokenValues = new HashMap<String, Object>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] modules = resolver.listTokenValues(new String[] {IvyPatternHelper.MODULE_KEY},
tokenValues);
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] modules = resolver.listTokenValues(
new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
for (int i = 0; i < modules.length; i++) {
entries.add(modules[i].get(IvyPatternHelper.MODULE_KEY));
}
}
return (String[]) entries.toArray(new String[entries.size()]);
return entries.toArray(new String[entries.size()]);
}
public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
Set entries = new HashSet();
Set<RevisionEntry> entries = new HashSet<RevisionEntry>();
Map tokenValues = new HashMap();
Map<String, Object> tokenValues = new HashMap<String, Object>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, module.getOrganisation());
tokenValues.put(IvyPatternHelper.MODULE_KEY, module.getModule());
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] revisions = resolver.listTokenValues(
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] revisions = resolver.listTokenValues(
new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues);
for (int i = 0; i < revisions.length; i++) {
String revision = (String) revisions[i].get(IvyPatternHelper.REVISION_KEY);
String revision = revisions[i].get(IvyPatternHelper.REVISION_KEY);
entries.add(new RevisionEntry(module, revision));
}
}
return (RevisionEntry[]) entries.toArray(new RevisionEntry[entries.size()]);
return entries.toArray(new RevisionEntry[entries.size()]);
}
public String[] listRevisions(String org, String module) {
Set entries = new HashSet();
Set<String> entries = new HashSet<String>();
Map tokenValues = new HashMap();
Map<String, Object> tokenValues = new HashMap<String, Object>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
tokenValues.put(IvyPatternHelper.MODULE_KEY, module);
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] revisions = resolver.listTokenValues(
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] revisions = resolver.listTokenValues(
new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues);
for (int i = 0; i < revisions.length; i++) {
entries.add(revisions[i].get(IvyPatternHelper.REVISION_KEY));
}
}
return (String[]) entries.toArray(new String[entries.size()]);
return entries.toArray(new String[entries.size()]);
}
/**
@ -189,9 +182,9 @@ public class SearchEngine {
* @return
*/
public ModuleId[] listModules(ModuleId moduleCrit, PatternMatcher matcher) {
List ret = new ArrayList();
List<ModuleId> ret = new ArrayList<ModuleId>();
Map criteria = new HashMap();
Map<String, Object> criteria = new HashMap<String, Object>();
addMatcher(matcher, moduleCrit.getOrganisation(), criteria,
IvyPatternHelper.ORGANISATION_KEY);
addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);
@ -199,19 +192,18 @@ public class SearchEngine {
String[] tokensToList = new String[] {IvyPatternHelper.ORGANISATION_KEY,
IvyPatternHelper.MODULE_KEY};
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
for (int i = 0; i < moduleIdAsMap.length; i++) {
String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
String org = moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
String name = moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
ModuleId modId = ModuleId.newInstance(org, name);
ret.add(NameSpaceHelper.transform(modId, resolver.getNamespace()
.getToSystemTransformer()));
}
}
return (ModuleId[]) ret.toArray(new ModuleId[ret.size()]);
return ret.toArray(new ModuleId[ret.size()]);
}
/**
@ -226,37 +218,33 @@ public class SearchEngine {
* @return
*/
public ModuleRevisionId[] listModules(ModuleRevisionId moduleCrit, PatternMatcher matcher) {
List ret = new ArrayList();
List<ModuleRevisionId> ret = new ArrayList<ModuleRevisionId>();
Map criteria = new HashMap();
for (Iterator it = moduleCrit.getAttributes().entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Entry) it.next();
addMatcher(matcher, (String) entry.getValue(), criteria, (String) entry.getKey());
Map<String, Object> criteria = new HashMap<String, Object>();
for (Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
addMatcher(matcher, entry.getValue(), criteria, entry.getKey());
}
String[] tokensToList = (String[]) moduleCrit.getAttributes().keySet()
String[] tokensToList = moduleCrit.getAttributes().keySet()
.toArray(new String[moduleCrit.getAttributes().size()]);
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
for (int i = 0; i < moduleIdAsMap.length; i++) {
String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
String branch = (String) moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
String rev = (String) moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
String org = moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
String name = moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
String branch = moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
String rev = moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
Map foundExtraAtts = new HashMap();
Set qualAttributes = moduleCrit.getQualifiedExtraAttributes().keySet();
for (Iterator iter2 = qualAttributes.iterator(); iter2.hasNext();) {
String qualifiedKey = (String) iter2.next();
Map<String, String> foundExtraAtts = new HashMap<String, String>();
Set<String> qualAttributes = moduleCrit.getQualifiedExtraAttributes().keySet();
for (String qualifiedKey : qualAttributes) {
String value = null;
int colonIndex = qualifiedKey.indexOf(':');
if (colonIndex == -1) {
value = (String) moduleIdAsMap[i].get(qualifiedKey);
value = moduleIdAsMap[i].get(qualifiedKey);
} else {
value = (String) moduleIdAsMap[i].get(qualifiedKey
.substring(colonIndex + 1));
value = moduleIdAsMap[i].get(qualifiedKey.substring(colonIndex + 1));
}
if (value != null) {
@ -270,7 +258,7 @@ public class SearchEngine {
}
}
return (ModuleRevisionId[]) ret.toArray(new ModuleRevisionId[ret.size()]);
return ret.toArray(new ModuleRevisionId[ret.size()]);
}
/**
@ -289,33 +277,32 @@ public class SearchEngine {
*/
public ModuleRevisionId[] listModules(DependencyResolver resolver, ModuleRevisionId moduleCrit,
PatternMatcher matcher) {
Map criteria = new HashMap();
for (Iterator it = moduleCrit.getAttributes().entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Entry) it.next();
addMatcher(matcher, (String) entry.getValue(), criteria, (String) entry.getKey());
Map<String, Object> criteria = new HashMap<String, Object>();
for (Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
addMatcher(matcher, entry.getValue(), criteria, entry.getKey());
}
String[] tokensToList = (String[]) moduleCrit.getAttributes().keySet()
String[] tokensToList = moduleCrit.getAttributes().keySet()
.toArray(new String[moduleCrit.getAttributes().size()]);
Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
Set result = new LinkedHashSet(); // we use a Set to remove duplicates
Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
Set<ModuleRevisionId> result = new LinkedHashSet<ModuleRevisionId>(); // we use a Set to
// remove duplicates
for (int i = 0; i < moduleIdAsMap.length; i++) {
String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
String branch = (String) moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
String rev = (String) moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
String org = moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
String name = moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
String branch = moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
String rev = moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
Map foundExtraAtts = new HashMap();
Set qualExtraAttributes = moduleCrit.getQualifiedExtraAttributes().keySet();
for (Iterator iter2 = qualExtraAttributes.iterator(); iter2.hasNext();) {
String qualifiedKey = (String) iter2.next();
Map<String, String> foundExtraAtts = new HashMap<String, String>();
Set<String> qualExtraAttributes = moduleCrit.getQualifiedExtraAttributes().keySet();
for (String qualifiedKey : qualExtraAttributes) {
String value = null;
int colonIndex = qualifiedKey.indexOf(':');
if (colonIndex == -1) {
value = (String) moduleIdAsMap[i].get(qualifiedKey);
value = moduleIdAsMap[i].get(qualifiedKey);
} else {
value = (String) moduleIdAsMap[i].get(qualifiedKey.substring(colonIndex + 1));
value = moduleIdAsMap[i].get(qualifiedKey.substring(colonIndex + 1));
}
if (value != null) {
@ -328,11 +315,11 @@ public class SearchEngine {
result.add(resolver.getNamespace().getToSystemTransformer().transform(modRevId));
}
return (ModuleRevisionId[]) result.toArray(new ModuleRevisionId[result.size()]);
return result.toArray(new ModuleRevisionId[result.size()]);
}
private void addMatcher(PatternMatcher patternMatcher, String expression, Map criteria,
String key) {
private void addMatcher(PatternMatcher patternMatcher, String expression,
Map<String, Object> criteria, String key) {
if (expression == null) {
return;
}
@ -345,9 +332,9 @@ public class SearchEngine {
}
}
public Collection findModuleRevisionIds(DependencyResolver resolver, ModuleRevisionId pattern,
PatternMatcher matcher) {
Collection mrids = new ArrayList();
public Collection<ModuleRevisionId> findModuleRevisionIds(DependencyResolver resolver,
ModuleRevisionId pattern, PatternMatcher matcher) {
Collection<ModuleRevisionId> mrids = new ArrayList<ModuleRevisionId>();
String resolverName = resolver.getName();
Message.verbose("looking for modules matching " + pattern + " using " + matcher.getName());
@ -356,7 +343,7 @@ public class SearchEngine {
fromNamespace = ((AbstractResolver) resolver).getNamespace();
}
Collection modules = new ArrayList();
Collection<ModuleEntry> modules = new ArrayList<ModuleEntry>();
OrganisationEntry[] orgs = resolver.listOrganisations();
if (orgs == null || orgs.length == 0) {
@ -386,8 +373,7 @@ public class SearchEngine {
Message.debug("found " + modules.size() + " modules for " + pattern.getOrganisation()
+ " on " + resolverName);
boolean foundModule = false;
for (Iterator iter = modules.iterator(); iter.hasNext();) {
ModuleEntry mEntry = (ModuleEntry) iter.next();
for (ModuleEntry mEntry : modules) {
ModuleId foundMid = new ModuleId(mEntry.getOrganisation(), mEntry.getModule());
ModuleId systemMid = foundMid;

View File

@ -31,10 +31,10 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.ivy.Ivy;
@ -76,6 +76,7 @@ import org.apache.ivy.plugins.latest.LatestLexicographicStrategy;
import org.apache.ivy.plugins.latest.LatestRevisionStrategy;
import org.apache.ivy.plugins.latest.LatestStrategy;
import org.apache.ivy.plugins.latest.LatestTimeStrategy;
import org.apache.ivy.plugins.latest.WorkspaceLatestStrategy;
import org.apache.ivy.plugins.lock.CreateFileLockStrategy;
import org.apache.ivy.plugins.lock.LockStrategy;
import org.apache.ivy.plugins.lock.NIOFileLockStrategy;
@ -92,10 +93,12 @@ import org.apache.ivy.plugins.parser.ParserSettings;
import org.apache.ivy.plugins.report.LogReportOutputter;
import org.apache.ivy.plugins.report.ReportOutputter;
import org.apache.ivy.plugins.report.XmlReportOutputter;
import org.apache.ivy.plugins.resolver.AbstractWorkspaceResolver;
import org.apache.ivy.plugins.resolver.ChainResolver;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.DualResolver;
import org.apache.ivy.plugins.resolver.ResolverSettings;
import org.apache.ivy.plugins.resolver.WorkspaceChainResolver;
import org.apache.ivy.plugins.signer.SignatureGenerator;
import org.apache.ivy.plugins.trigger.Trigger;
import org.apache.ivy.plugins.version.ChainVersionMatcher;
@ -115,9 +118,9 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
ResolveEngineSettings, RetrieveEngineSettings, RepositoryManagementEngineSettings {
private static final long INTERUPT_TIMEOUT = 2000;
private Map typeDefs = new HashMap();
private Map<String, Class<?>> typeDefs = new HashMap<String, Class<?>>();
private Map resolversMap = new HashMap();
private Map<String, DependencyResolver> resolversMap = new HashMap<String, DependencyResolver>();
private DependencyResolver defaultResolver;
@ -131,40 +134,29 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
private boolean checkUpToDate = true;
private ModuleRules moduleSettings = new ModuleRules();
private ModuleRules<ModuleSettings> moduleSettings = new ModuleRules<ModuleSettings>();
// Map (String conflictManagerName -> ConflictManager)
private Map conflictsManager = new HashMap();
private Map<String, ConflictManager> conflictsManager = new HashMap<String, ConflictManager>();
// Map (String latestStrategyName -> LatestStrategy)
private Map latestStrategies = new HashMap();
private Map<String, LatestStrategy> latestStrategies = new HashMap<String, LatestStrategy>();
// Map (String name -> LockStrategy)
private Map lockStrategies = new HashMap();
private Map<String, LockStrategy> lockStrategies = new HashMap<String, LockStrategy>();
// Map (String namespaceName -> Namespace)
private Map namespaces = new HashMap();
private Map<String, Namespace> namespaces = new HashMap<String, Namespace>();
// Map (String matcherName -> Matcher)
private Map matchers = new HashMap();
private Map<String, PatternMatcher> matchers = new HashMap<String, PatternMatcher>();
// Map (String outputterName -> ReportOutputter)
private Map reportOutputters = new HashMap();
private Map<String, ReportOutputter> reportOutputters = new HashMap<String, ReportOutputter>();
// Map (String matcherName -> VersionMatcher)
private Map versionMatchers = new HashMap();
private Map<String, VersionMatcher> versionMatchers = new HashMap<String, VersionMatcher>();
// Map (String name -> CircularDependencyStrategy)
private Map circularDependencyStrategies = new HashMap();
private Map<String, CircularDependencyStrategy> circularDependencyStrategies = new HashMap<String, CircularDependencyStrategy>();
// Map (String name -> RepositoryCacheManager)
private Map repositoryCacheManagers = new HashMap();
private Map<String, RepositoryCacheManager> repositoryCacheManagers = new HashMap<String, RepositoryCacheManager>();
// Map (String name -> SignatureGenerator)
private Map signatureGenerators = new HashMap();
private Map<String, SignatureGenerator> signatureGenerators = new HashMap<String, SignatureGenerator>();
// List (Trigger)
private List triggers = new ArrayList();
private List<Trigger> triggers = new ArrayList<Trigger>();
private IvyVariableContainer variableContainer = new IvyVariableContainerImpl();
@ -182,7 +174,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
private ResolutionCacheManager resolutionCacheManager = null;
private List listingIgnore = new ArrayList();
private List<String> listingIgnore = new ArrayList<String>();
private boolean repositoriesConfigured;
@ -192,7 +184,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
private File baseDir = new File(".").getAbsoluteFile();
private List classpathURLs = new ArrayList();
private List<URL> classpathURLs = new ArrayList<URL>();
private ClassLoader classloader;
@ -218,6 +210,8 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
private PackingRegistry packingRegistry = new PackingRegistry();
private AbstractWorkspaceResolver workspaceResolver;
public IvySettings() {
this(new IvyVariableContainerImpl());
}
@ -278,8 +272,10 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
try {
// GlobPatternMatcher is optional. Only add it when available.
Class globClazz = IvySettings.class.getClassLoader().loadClass(
"org.apache.ivy.plugins.matcher.GlobPatternMatcher");
@SuppressWarnings("unchecked")
Class<? extends PatternMatcher> globClazz = (Class<? extends PatternMatcher>) IvySettings.class
.getClassLoader()
.loadClass("org.apache.ivy.plugins.matcher.GlobPatternMatcher");
Field instanceField = globClazz.getField("INSTANCE");
addMatcher((PatternMatcher) instanceField.get(null));
} catch (Exception e) {
@ -305,7 +301,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
private synchronized void addSystemProperties() {
try {
addAllVariables((Map) System.getProperties().clone());
addAllVariables((Map<?, ?>) System.getProperties().clone());
} catch (AccessControlException ex) {
Message.verbose("access denied to getting all system properties: they won't be available as Ivy variables."
+ "\nset " + ex.getPermission() + " permission if you want to access them");
@ -371,9 +367,9 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized void typeDefs(Properties p, boolean silentFail) {
for (Iterator iter = p.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
typeDef(name, p.getProperty(name), silentFail);
for (Entry<Object, Object> entry : p.entrySet()) {
String name = entry.getKey().toString();
typeDef(name, entry.getValue().toString(), silentFail);
}
}
@ -532,13 +528,12 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
if (!classpathURLs.isEmpty()) {
Message.verbose("\t-- " + classpathURLs.size() + " custom classpath urls:");
for (Iterator iter = classpathURLs.iterator(); iter.hasNext();) {
Message.debug("\t\t" + iter.next());
for (URL url : classpathURLs) {
Message.debug("\t\t" + url);
}
}
Message.verbose("\t-- " + resolversMap.size() + " resolvers:");
for (Iterator iter = resolversMap.values().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
for (DependencyResolver resolver : resolversMap.values()) {
resolver.dumpSettings();
}
Message.debug("\tmodule settings:");
@ -600,7 +595,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
variableContainer.setVariable(varName, value, overwrite);
}
public synchronized void addAllVariables(Map variables) {
public synchronized void addAllVariables(Map<?, ?> variables) {
addAllVariables(variables, true);
}
@ -635,11 +630,10 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
* @return a new map of strings in which all current ivy variables in values have been
* substituted by their value
*/
public synchronized Map/* <String, String> */substitute(Map/* <String, String> */strings) {
Map substituted = new LinkedHashMap();
for (Iterator it = strings.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
substituted.put(entry.getKey(), substitute((String) entry.getValue()));
public synchronized Map<String, String> substitute(Map<String, String> strings) {
Map<String, String> substituted = new LinkedHashMap<String, String>();
for (Entry<String, String> entry : strings.entrySet()) {
substituted.put(entry.getKey(), substitute(entry.getValue()));
}
return substituted;
}
@ -654,19 +648,19 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
return variableContainer;
}
public synchronized Class typeDef(String name, String className) {
public synchronized Class<?> typeDef(String name, String className) {
return typeDef(name, className, false);
}
public synchronized Class typeDef(String name, String className, boolean silentFail) {
Class clazz = classForName(className, silentFail);
public synchronized Class<?> typeDef(String name, String className, boolean silentFail) {
Class<?> clazz = classForName(className, silentFail);
if (clazz != null) {
typeDefs.put(name, clazz);
}
return clazz;
}
private Class classForName(String className, boolean silentFail) {
private Class<?> classForName(String className, boolean silentFail) {
try {
return getClassLoader().loadClass(className);
} catch (ClassNotFoundException e) {
@ -687,7 +681,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
classloader = Ivy.class.getClassLoader();
} else {
classloader = new URLClassLoader(
(URL[]) classpathURLs.toArray(new URL[classpathURLs.size()]),
classpathURLs.toArray(new URL[classpathURLs.size()]),
Ivy.class.getClassLoader());
}
}
@ -699,12 +693,12 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
classloader = null;
}
public synchronized Map getTypeDefs() {
public synchronized Map<String, Class<?>> getTypeDefs() {
return typeDefs;
}
public synchronized Class getTypeDef(String name) {
return (Class) typeDefs.get(name);
public synchronized Class<?> getTypeDef(String name) {
return typeDefs.get(name);
}
// methods which match ivy conf method signature specs
@ -726,7 +720,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized SignatureGenerator getSignatureGenerator(String name) {
return (SignatureGenerator) signatureGenerators.get(name);
return signatureGenerators.get(name);
}
public synchronized void addResolver(DependencyResolver resolver) {
@ -736,9 +730,8 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
init(resolver);
resolversMap.put(resolver.getName(), resolver);
if (resolver instanceof ChainResolver) {
List subresolvers = ((ChainResolver) resolver).getResolvers();
for (Iterator iter = subresolvers.iterator(); iter.hasNext();) {
DependencyResolver dr = (DependencyResolver) iter.next();
List<DependencyResolver> subresolvers = ((ChainResolver) resolver).getResolvers();
for (DependencyResolver dr : subresolvers) {
addResolver(dr);
}
} else if (resolver instanceof DualResolver) {
@ -783,8 +776,9 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
/**
* regular expressions as explained in Pattern class may be used in attributes
*/
public synchronized void addModuleConfiguration(Map attributes, PatternMatcher matcher,
String resolverName, String branch, String conflictManager, String resolveMode) {
public synchronized void addModuleConfiguration(Map<String, String> attributes,
PatternMatcher matcher, String resolverName, String branch, String conflictManager,
String resolveMode) {
checkResolverName(resolverName);
moduleSettings.defineRule(new MapMatcher(attributes, matcher), new ModuleSettings(
resolverName, branch, conflictManager, resolveMode));
@ -890,9 +884,20 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
dictatorResolver = resolver;
}
private DependencyResolver getDictatorResolver() {
if (dictatorResolver == null) {
return null;
}
if (workspaceResolver != null && !(dictatorResolver instanceof WorkspaceChainResolver)) {
dictatorResolver = new WorkspaceChainResolver(this, dictatorResolver, workspaceResolver);
}
return dictatorResolver;
}
public synchronized DependencyResolver getResolver(ModuleRevisionId mrid) {
if (dictatorResolver != null) {
return dictatorResolver;
DependencyResolver r = getDictatorResolver();
if (r != null) {
return r;
}
String resolverName = getResolverName(mrid);
return getResolver(resolverName);
@ -903,39 +908,48 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized DependencyResolver getResolver(String resolverName) {
if (dictatorResolver != null) {
return dictatorResolver;
DependencyResolver r = getDictatorResolver();
if (r != null) {
return r;
}
DependencyResolver resolver = (DependencyResolver) resolversMap.get(resolverName);
DependencyResolver resolver = resolversMap.get(resolverName);
if (resolver == null) {
Message.error("unknown resolver " + resolverName);
} else if (workspaceResolver != null && !(resolver instanceof WorkspaceChainResolver)) {
resolver = new WorkspaceChainResolver(this, resolver, workspaceResolver);
resolversMap.put(resolver.getName(), resolver);
resolversMap.put(resolverName, resolver);
}
return resolver;
}
public synchronized DependencyResolver getDefaultResolver() {
if (dictatorResolver != null) {
return dictatorResolver;
DependencyResolver r = getDictatorResolver();
if (r != null) {
return r;
}
if (defaultResolver == null) {
defaultResolver = (DependencyResolver) resolversMap.get(defaultResolverName);
defaultResolver = resolversMap.get(defaultResolverName);
}
if (workspaceResolver != null && !(defaultResolver instanceof WorkspaceChainResolver)) {
defaultResolver = new WorkspaceChainResolver(this, defaultResolver, workspaceResolver);
}
return defaultResolver;
}
public synchronized String getResolverName(ModuleRevisionId mrid) {
ModuleSettings ms = (ModuleSettings) moduleSettings.getRule(mrid, new Filter() {
public boolean accept(Object o) {
return ((ModuleSettings) o).getResolverName() != null;
ModuleSettings ms = moduleSettings.getRule(mrid, new Filter<ModuleSettings>() {
public boolean accept(ModuleSettings o) {
return o.getResolverName() != null;
}
});
return ms == null ? defaultResolverName : ms.getResolverName();
}
public synchronized String getDefaultBranch(ModuleId moduleId) {
ModuleSettings ms = (ModuleSettings) moduleSettings.getRule(moduleId, new Filter() {
public boolean accept(Object o) {
return ((ModuleSettings) o).getBranch() != null;
ModuleSettings ms = moduleSettings.getRule(moduleId, new Filter<ModuleSettings>() {
public boolean accept(ModuleSettings o) {
return o.getBranch() != null;
}
});
return ms == null ? getDefaultBranch() : ms.getBranch();
@ -950,9 +964,9 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized ConflictManager getConflictManager(ModuleId moduleId) {
ModuleSettings ms = (ModuleSettings) moduleSettings.getRule(moduleId, new Filter() {
public boolean accept(Object o) {
return ((ModuleSettings) o).getConflictManager() != null;
ModuleSettings ms = moduleSettings.getRule(moduleId, new Filter<ModuleSettings>() {
public boolean accept(ModuleSettings o) {
return o.getConflictManager() != null;
}
});
if (ms == null) {
@ -968,9 +982,9 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized String getResolveMode(ModuleId moduleId) {
ModuleSettings ms = (ModuleSettings) moduleSettings.getRule(moduleId, new Filter() {
public boolean accept(Object o) {
return ((ModuleSettings) o).getResolveMode() != null;
ModuleSettings ms = moduleSettings.getRule(moduleId, new Filter<ModuleSettings>() {
public boolean accept(ModuleSettings o) {
return o.getResolveMode() != null;
}
});
return ms == null ? getDefaultResolveMode() : ms.getResolveMode();
@ -992,7 +1006,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
if ("default".equals(name)) {
return getDefaultConflictManager();
}
return (ConflictManager) conflictsManager.get(name);
return conflictsManager.get(name);
}
public synchronized void addConflictManager(String name, ConflictManager cm) {
@ -1008,7 +1022,12 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
if ("default".equals(name)) {
return getDefaultLatestStrategy();
}
return (LatestStrategy) latestStrategies.get(name);
LatestStrategy strategy = latestStrategies.get(name);
if (workspaceResolver != null && !(strategy instanceof WorkspaceLatestStrategy)) {
strategy = new WorkspaceLatestStrategy(strategy);
latestStrategies.put(name, strategy);
}
return strategy;
}
public synchronized void addLatestStrategy(String name, LatestStrategy latest) {
@ -1024,7 +1043,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
if ("default".equals(name)) {
return getDefaultLockStrategy();
}
return (LockStrategy) lockStrategies.get(name);
return lockStrategies.get(name);
}
public synchronized void addLockStrategy(String name, LockStrategy lockStrategy) {
@ -1040,7 +1059,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
if ("system".equals(name)) {
return getSystemNamespace();
}
return (Namespace) namespaces.get(name);
return namespaces.get(name);
}
public final Namespace getSystemNamespace() {
@ -1057,7 +1076,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized PatternMatcher getMatcher(String name) {
return (PatternMatcher) matchers.get(name);
return matchers.get(name);
}
public synchronized void addMatcher(PatternMatcher m) {
@ -1070,7 +1089,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized RepositoryCacheManager getRepositoryCacheManager(String name) {
return (RepositoryCacheManager) repositoryCacheManagers.get(name);
return repositoryCacheManagers.get(name);
}
public synchronized void addRepositoryCacheManager(RepositoryCacheManager c) {
@ -1079,7 +1098,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized RepositoryCacheManager[] getRepositoryCacheManagers() {
return (RepositoryCacheManager[]) repositoryCacheManagers.values().toArray(
return repositoryCacheManagers.values().toArray(
new RepositoryCacheManager[repositoryCacheManagers.size()]);
}
@ -1088,7 +1107,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized ReportOutputter getReportOutputter(String name) {
return (ReportOutputter) reportOutputters.get(name);
return reportOutputters.get(name);
}
public synchronized void addReportOutputter(ReportOutputter outputter) {
@ -1097,8 +1116,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized ReportOutputter[] getReportOutputters() {
return (ReportOutputter[]) reportOutputters.values().toArray(
new ReportOutputter[reportOutputters.size()]);
return reportOutputters.values().toArray(new ReportOutputter[reportOutputters.size()]);
}
public synchronized void addConfigured(VersionMatcher vmatcher) {
@ -1106,7 +1124,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized VersionMatcher getVersionMatcher(String name) {
return (VersionMatcher) versionMatchers.get(name);
return versionMatchers.get(name);
}
public synchronized void addVersionMatcher(VersionMatcher vmatcher) {
@ -1124,8 +1142,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized VersionMatcher[] getVersionMatchers() {
return (VersionMatcher[]) versionMatchers.values().toArray(
new VersionMatcher[versionMatchers.size()]);
return versionMatchers.values().toArray(new VersionMatcher[versionMatchers.size()]);
}
public synchronized VersionMatcher getVersionMatcher() {
@ -1152,7 +1169,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
if ("default".equals(name)) {
name = "warn";
}
return (CircularDependencyStrategy) circularDependencyStrategies.get(name);
return circularDependencyStrategies.get(name);
}
public synchronized void setCircularDependencyStrategy(CircularDependencyStrategy strategy) {
@ -1188,7 +1205,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
* Returns the file names of the files that should be ignored when creating a file listing.
*/
public synchronized String[] getIgnorableFilenames() {
return (String[]) listingIgnore.toArray(new String[listingIgnore.size()]);
return listingIgnore.toArray(new String[listingIgnore.size()]);
}
/**
@ -1197,7 +1214,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
*
* @param names
*/
public synchronized void filterIgnore(Collection names) {
public synchronized void filterIgnore(Collection<String> names) {
names.removeAll(listingIgnore);
}
@ -1237,6 +1254,10 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
if (defaultLatestStrategy == null) {
defaultLatestStrategy = new LatestRevisionStrategy();
}
if (workspaceResolver != null
&& !(defaultLatestStrategy instanceof WorkspaceLatestStrategy)) {
defaultLatestStrategy = new WorkspaceLatestStrategy(defaultLatestStrategy);
}
return defaultLatestStrategy;
}
@ -1286,7 +1307,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
triggers.add(trigger);
}
public synchronized List getTriggers() {
public synchronized List<Trigger> getTriggers() {
return triggers;
}
@ -1375,6 +1396,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
this.resolveMode = resolveMode;
}
@Override
public String toString() {
return (resolverName != null ? "resolver: " + resolverName : "")
+ (branch != null ? "branch: " + branch : "")
@ -1403,15 +1425,15 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
return INTERUPT_TIMEOUT;
}
public synchronized Collection getResolvers() {
public synchronized Collection<DependencyResolver> getResolvers() {
return resolversMap.values();
}
public synchronized Collection getResolverNames() {
public synchronized Collection<String> getResolverNames() {
return resolversMap.keySet();
}
public synchronized Collection getMatcherNames() {
public synchronized Collection<String> getMatcherNames() {
return matchers.keySet();
}
@ -1492,9 +1514,8 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
* @throws IllegalStateException
* if any of the objects is not valid.
*/
private void validateAll(Collection values) {
for (Iterator iterator = values.iterator(); iterator.hasNext();) {
Object object = iterator.next();
private void validateAll(Collection<?> values) {
for (Object object : values) {
if (object instanceof Validatable) {
((Validatable) object).validate();
}
@ -1513,4 +1534,20 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
public PackingRegistry getPackingRegistry() {
return packingRegistry;
}
public void addConfigured(AbstractWorkspaceResolver workspaceResolver) {
this.workspaceResolver = workspaceResolver;
if (workspaceResolver != null) {
workspaceResolver.setSettings(this);
DefaultRepositoryCacheManager cacheManager = new DefaultRepositoryCacheManager();
String cacheName = "workspace-resolver-cache-" + workspaceResolver.getName();
cacheManager.setBasedir(new File(getDefaultCache(), cacheName));
cacheManager.setCheckmodified(true);
cacheManager.setUseOrigin(true);
cacheManager.setName(cacheName);
addRepositoryCacheManager(cacheManager);
workspaceResolver.setCache(cacheName);
}
}
}

View File

@ -62,14 +62,24 @@ public class OSGiManifestParser implements ModuleDescriptorParser {
public ModuleDescriptor parseDescriptor(ParserSettings ivySettings, URL descriptorURL,
Resource res, boolean validate) throws ParseException, IOException {
Manifest m = new Manifest(res.openStream());
BundleInfo bundleInfo = ManifestParser.parseManifest(m);
final InputStream resourceStream = res.openStream();
final Manifest manifest;
try {
bundleInfo.addArtifact(new BundleArtifact(false, new URI(res.getName()), null));
manifest = new Manifest(resourceStream);
} finally {
try {
resourceStream.close();
} catch (Exception e) {
// ignore
}
}
BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
try {
bundleInfo.addArtifact(new BundleArtifact(false, descriptorURL.toURI(), null));
} catch (URISyntaxException e) {
throw new RuntimeException("Unsupported repository, resources names are not uris", e);
}
return BundleInfoAdapter.toModuleDescriptor(this, null, bundleInfo, m, profileProvider);
return BundleInfoAdapter.toModuleDescriptor(this, null, bundleInfo, manifest, profileProvider);
}
public void toIvyFile(InputStream is, Resource res, File destFile, ModuleDescriptor md)

View File

@ -29,6 +29,7 @@ public class AndFilter extends MultiOperatorFilter {
super(filters);
}
@Override
protected char operator() {
return '&';
}

View File

@ -24,7 +24,7 @@ public class CompareFilter extends OSGiFilter {
public static enum Operator {
EQUALS("="), LOWER_THAN("<"), LOWER_OR_EQUAL("<="), GREATER_THAN(">"), GREATER_OR_EQUAL(
">=");
">="), APPROX("~="), PRESENT("=*");
private String op;
@ -32,6 +32,7 @@ public class CompareFilter extends OSGiFilter {
this.op = op;
}
@Override
public String toString() {
return op;
}
@ -43,10 +44,13 @@ public class CompareFilter extends OSGiFilter {
private final String leftValue;
private boolean substring;
public CompareFilter(String leftValue, Operator operator, String rightValue) {
this.leftValue = leftValue;
this.rightValue = rightValue;
this.operator = operator;
this.substring = operator == Operator.EQUALS && rightValue.contains("*");
}
public String getLeftValue() {
@ -61,6 +65,7 @@ public class CompareFilter extends OSGiFilter {
return rightValue;
}
@Override
public void append(StringBuffer builder) {
builder.append("(");
builder.append(leftValue);
@ -75,6 +80,17 @@ public class CompareFilter extends OSGiFilter {
if (actualValue == null) {
return false;
}
if (operator == Operator.PRESENT) {
return true;
}
if (operator == Operator.APPROX) {
// TODO
return false;
}
if (substring) {
// TODO
return false;
}
int diff = rightValue.compareTo(actualValue);
switch (operator) {
case EQUALS:
@ -92,6 +108,7 @@ public class CompareFilter extends OSGiFilter {
}
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
@ -101,6 +118,7 @@ public class CompareFilter extends OSGiFilter {
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;

View File

@ -37,6 +37,7 @@ public abstract class MultiOperatorFilter extends OSGiFilter {
abstract protected char operator();
@Override
public void append(StringBuffer builder) {
builder.append('(');
builder.append(operator());
@ -54,6 +55,7 @@ public abstract class MultiOperatorFilter extends OSGiFilter {
return subFilters;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
@ -63,6 +65,7 @@ public abstract class MultiOperatorFilter extends OSGiFilter {
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;

View File

@ -25,6 +25,7 @@ public class NotFilter extends UniOperatorFilter {
super(subFilter);
}
@Override
protected char operator() {
return '!';
}

View File

@ -21,6 +21,7 @@ import java.util.Map;
public abstract class OSGiFilter {
@Override
public String toString() {
StringBuffer builder = new StringBuffer();
append(builder);

View File

@ -92,6 +92,15 @@ public class OSGiFilterParser {
if (c != '(') {
throw new ParseException("Expecting '(' as the start of the filter", pos);
}
OSGiFilter filter = parseFilterComp();
readNext();
if (c != ')') {
throw new ParseException("Expecting ')' as the end of the filter", pos);
}
return filter;
}
private OSGiFilter parseFilterComp() throws ParseException {
OSGiFilter filter;
switch (readNext()) {
case '&':
@ -105,17 +114,13 @@ public class OSGiFilterParser {
break;
default:
unread();
filter = parseCompare();
filter = parseOperation();
break;
}
readNext();
if (c != ')') {
throw new ParseException("Expecting ')' as the end of the filter", pos);
}
return filter;
}
private OSGiFilter parseCompare() throws ParseException {
private OSGiFilter parseOperation() throws ParseException {
String leftValue = parseCompareValue();
Operator operator = parseCompareOperator();
String rightValue = parseCompareValue();
@ -137,12 +142,16 @@ public class OSGiFilterParser {
}
private boolean isOperator(char ch) {
return ch == '=' || ch == '<' || ch == '>';
return ch == '=' || ch == '<' || ch == '>' || ch == '~';
}
private Operator parseCompareOperator() throws ParseException {
switch (readNext()) {
case '=':
if (readNext() == '*') {
return Operator.PRESENT;
}
unread();
return Operator.EQUALS;
case '>':
if (readNext() == '=') {
@ -156,25 +165,30 @@ public class OSGiFilterParser {
}
unread();
return Operator.LOWER_THAN;
case '~':
if (readNext() == '=') {
return Operator.LOWER_OR_EQUAL;
}
unread();
default:
break;
}
throw new ParseException("Expecting an operator: =, <, <=, > or >=", pos);
throw new ParseException("Expecting an operator: =, <, <=, >, >=, ~= or =*", pos);
}
private OSGiFilter parseAnd() throws ParseException {
AndFilter filter = new AndFilter();
parseMultiOperator(filter);
parseFilterList(filter);
return filter;
}
private OSGiFilter parseOr() throws ParseException {
OrFilter filter = new OrFilter();
parseMultiOperator(filter);
parseFilterList(filter);
return filter;
}
private void parseMultiOperator(MultiOperatorFilter filter) throws ParseException {
private void parseFilterList(MultiOperatorFilter filter) throws ParseException {
do {
skipWhiteSpace();
readNext();

View File

@ -29,6 +29,7 @@ public class OrFilter extends MultiOperatorFilter {
super(filters);
}
@Override
protected char operator() {
return '|';
}

View File

@ -27,6 +27,7 @@ public abstract class UniOperatorFilter extends OSGiFilter {
abstract protected char operator();
@Override
public void append(StringBuffer builder) {
builder.append("(");
builder.append(operator());
@ -38,6 +39,7 @@ public abstract class UniOperatorFilter extends OSGiFilter {
return subFilter;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
@ -45,6 +47,7 @@ public abstract class UniOperatorFilter extends OSGiFilter {
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;

View File

@ -25,7 +25,6 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import org.apache.ivy.core.cache.CacheResourceOptions;
import org.apache.ivy.core.event.EventManager;
@ -62,6 +61,7 @@ public class OBRResolver extends AbstractOSGiResolver {
this.forceMetadataUpdate = forceMetadataUpdate;
}
@Override
protected void init() {
if (repoXmlFile != null && repoXmlURL != null) {
throw new RuntimeException("The OBR repository resolver " + getName()
@ -125,10 +125,6 @@ public class OBRResolver extends AbstractOSGiResolver {
}
try {
setRepoDescriptor(OBRXMLParser.parse(baseUri, in));
} catch (ParseException e) {
throw new RuntimeException("The OBR repository resolver " + getName()
+ " couldn't be configured: the file " + sourceLocation
+ " is incorrectly formed (" + e.getMessage() + ")", e);
} catch (IOException e) {
throw new RuntimeException("The OBR repository resolver " + getName()
+ " couldn't be configured: the file " + sourceLocation

View File

@ -41,8 +41,8 @@ import org.xml.sax.SAXParseException;
public class OBRXMLParser {
public static BundleRepoDescriptor parse(URI baseUri, InputStream in) throws ParseException,
IOException, SAXException {
public static BundleRepoDescriptor parse(URI baseUri, InputStream in) throws IOException,
SAXException {
RepositoryHandler handler = new RepositoryHandler(baseUri);
try {
XMLHelper.parse(in, null, handler, null);
@ -68,12 +68,14 @@ public class OBRXMLParser {
super(REPOSITORY);
this.baseUri = baseUri;
addChild(new ResourceHandler(), new ChildElementHandler<ResourceHandler>() {
@Override
public void childHanlded(ResourceHandler child) {
repo.addBundle(child.bundleInfo);
}
});
}
@Override
protected void handleAttributes(Attributes atts) {
repo = new BundleRepoDescriptor(baseUri,
ExecutionEnvironmentProfileProvider.getInstance());
@ -109,6 +111,7 @@ public class OBRXMLParser {
// resource
addChild(new ResourceSourceHandler(), new ChildElementHandler<ResourceSourceHandler>() {
@Override
public void childHanlded(ResourceSourceHandler child) {
String uri = child.getBufferedChars().trim();
if (!uri.endsWith(".jar")) {
@ -129,23 +132,27 @@ public class OBRXMLParser {
});
addChild(new ResourceDescriptionHandler(),
new ChildElementHandler<ResourceDescriptionHandler>() {
@Override
public void childHanlded(ResourceDescriptionHandler child) {
bundleInfo.setDescription(child.getBufferedChars().trim());
}
});
addChild(new ResourceDocumentationHandler(),
new ChildElementHandler<ResourceDocumentationHandler>() {
@Override
public void childHanlded(ResourceDocumentationHandler child) {
bundleInfo.setDocumentation(child.getBufferedChars().trim());
}
});
addChild(new ResourceLicenseHandler(),
new ChildElementHandler<ResourceLicenseHandler>() {
@Override
public void childHanlded(ResourceLicenseHandler child) {
bundleInfo.setLicense(child.getBufferedChars().trim());
}
});
addChild(new ResourceSizeHandler(), new ChildElementHandler<ResourceSizeHandler>() {
@Override
public void childHanlded(ResourceSizeHandler child) {
String size = child.getBufferedChars().trim();
try {
@ -158,6 +165,7 @@ public class OBRXMLParser {
}
});
addChild(new CapabilityHandler(), new ChildElementHandler<CapabilityHandler>() {
@Override
public void childHanlded(CapabilityHandler child) throws SAXParseException {
try {
@ -169,6 +177,7 @@ public class OBRXMLParser {
}
});
addChild(new RequireHandler(), new ChildElementHandler<RequireHandler>() {
@Override
public void childHanlded(RequireHandler child) throws SAXParseException {
try {
RequirementAdapter.adapt(bundleInfo, child.requirement);
@ -183,12 +192,14 @@ public class OBRXMLParser {
}
});
addChild(new ExtendHandler(), new ChildElementHandler<ExtendHandler>() {
@Override
public void childHanlded(ExtendHandler child) throws SAXParseException {
// TODO handle fragment host
}
});
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String symbolicname = atts.getValue(SYMBOLIC_NAME);
if (symbolicname == null) {
@ -224,6 +235,7 @@ public class OBRXMLParser {
bundleInfo.setId(atts.getValue(ID));
}
@Override
protected String getCurrentElementIdentifier() {
return bundleInfo.getSymbolicName() + "/" + bundleInfo.getVersion();
}
@ -295,6 +307,7 @@ public class OBRXMLParser {
super(CAPABILITY);
addChild(new CapabilityPropertyHandler(),
new ChildElementHandler<CapabilityPropertyHandler>() {
@Override
public void childHanlded(CapabilityPropertyHandler child) {
String name = child.name;
String value = child.value;
@ -305,6 +318,7 @@ public class OBRXMLParser {
});
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String name = getRequiredAttribute(atts, NAME);
capability = new Capability(name);
@ -332,6 +346,7 @@ public class OBRXMLParser {
super(CAPABILITY_PROPERTY);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
name = getRequiredAttribute(atts, NAME);
value = getRequiredAttribute(atts, VALUE);
@ -357,6 +372,7 @@ public class OBRXMLParser {
super(name);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String name = getRequiredAttribute(atts, NAME);

View File

@ -80,6 +80,7 @@ public class P2ArtifactParser implements XMLInputParser {
// }
// });
addChild(new MappingsHandler(), new ChildElementHandler<MappingsHandler>() {
@Override
public void childHanlded(MappingsHandler child) {
for (Entry<String, String> entry : child.outputByFilter.entrySet()) {
OSGiFilter filter;
@ -95,6 +96,7 @@ public class P2ArtifactParser implements XMLInputParser {
});
addChild(new ArtifactsHandler(p2Descriptor, artifactPatterns, repoUrl),
new ChildElementHandler<ArtifactsHandler>() {
@Override
public void childHanlded(ArtifactsHandler child) {
// nothing to do
}
@ -118,12 +120,14 @@ public class P2ArtifactParser implements XMLInputParser {
public MappingsHandler() {
super(MAPPINGS);
addChild(new RuleHandler(), new ChildElementHandler<RuleHandler>() {
@Override
public void childHanlded(RuleHandler child) {
outputByFilter.put(child.filter, child.output);
}
});
}
@Override
protected void handleAttributes(Attributes atts) {
int size = Integer.parseInt(atts.getValue(SIZE));
outputByFilter = new LinkedHashMap<String, String>(size);
@ -147,6 +151,7 @@ public class P2ArtifactParser implements XMLInputParser {
super(RULE);
}
@Override
protected void handleAttributes(Attributes atts) {
filter = atts.getValue(FILTER);
output = atts.getValue(OUTPUT);
@ -164,6 +169,7 @@ public class P2ArtifactParser implements XMLInputParser {
final Map<OSGiFilter, String> artifactPatterns, final String repoUrl) {
super(ARTIFACTS);
addChild(new ArtifactHandler(), new ChildElementHandler<ArtifactHandler>() {
@Override
public void childHanlded(ArtifactHandler child) throws SAXParseException {
String url = getPattern(child.p2Artifact, child.properties);
if (url != null) {
@ -224,12 +230,14 @@ public class P2ArtifactParser implements XMLInputParser {
public ArtifactHandler() {
super(ARTIFACT);
addChild(new PropertiesHandler(), new ChildElementHandler<PropertiesHandler>() {
@Override
public void childHanlded(PropertiesHandler child) {
properties = child.properties;
}
});
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String id = atts.getValue(ID);
Version version;

View File

@ -66,6 +66,7 @@ public class P2CompositeParser implements XMLInputParser {
public RepositoryHandler() {
super(REPOSITORY);
addChild(new ChildrenHandler(), new ChildElementHandler<ChildrenHandler>() {
@Override
public void childHanlded(ChildrenHandler child) {
childLocations = child.childLocations;
}
@ -89,12 +90,14 @@ public class P2CompositeParser implements XMLInputParser {
public ChildrenHandler() {
super(CHILDREN);
addChild(new ChildHandler(), new ChildElementHandler<ChildHandler>() {
@Override
public void childHanlded(ChildHandler child) {
childLocations.add(child.location);
}
});
}
@Override
protected void handleAttributes(Attributes atts) {
int size = Integer.parseInt(atts.getValue(SIZE));
childLocations = new ArrayList<String>(size);
@ -114,6 +117,7 @@ public class P2CompositeParser implements XMLInputParser {
super(CHILD);
}
@Override
protected void handleAttributes(Attributes atts) {
location = atts.getValue(LOCATION);
}

View File

@ -93,6 +93,7 @@ public class P2MetadataParser implements XMLInputParser {
// }
// });
addChild(new UnitsHandler(), new ChildElementHandler<UnitsHandler>() {
@Override
public void childHanlded(UnitsHandler child) {
for (BundleInfo bundle : child.bundles) {
p2Descriptor.addBundle(bundle);
@ -100,6 +101,7 @@ public class P2MetadataParser implements XMLInputParser {
}
});
addChild(new ReferencesHandler(), new ChildElementHandler<ReferencesHandler>() {
@Override
public void childHanlded(ReferencesHandler child) {
}
});
@ -126,12 +128,14 @@ public class P2MetadataParser implements XMLInputParser {
super(REFERENCES);
addChild(new RepositoryReferenceHandler(),
new ChildElementHandler<RepositoryReferenceHandler>() {
@Override
public void childHanlded(RepositoryReferenceHandler child) {
repositoryUris.add(child.uri);
}
});
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
int size = Integer.parseInt(atts.getValue(SIZE));
repositoryUris = new ArrayList<URI>(size);
@ -164,6 +168,7 @@ public class P2MetadataParser implements XMLInputParser {
URI uri;
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
// type = Integer.parseInt(atts.getValue(TYPE));
// options = Integer.parseInt(atts.getValue(OPTIONS));
@ -202,6 +207,7 @@ public class P2MetadataParser implements XMLInputParser {
public UnitsHandler() {
super(UNITS);
addChild(new UnitHandler(), new ChildElementHandler<UnitHandler>() {
@Override
public void childHanlded(UnitHandler child) {
if (child.bundleInfo != null && !child.bundleInfo.getCapabilities().isEmpty()) {
bundles.add(child.bundleInfo);
@ -210,6 +216,7 @@ public class P2MetadataParser implements XMLInputParser {
});
}
@Override
protected void handleAttributes(Attributes atts) {
int size = Integer.parseInt(atts.getValue(SIZE));
bundles = new ArrayList<BundleInfo>(size);
@ -239,6 +246,7 @@ public class P2MetadataParser implements XMLInputParser {
// });
addChild(new PropertiesHandler(CATEGORY_PROPERTY),
new ChildElementHandler<PropertiesHandler>() {
@Override
public void childHanlded(PropertiesHandler child) {
String category = child.properties.get(CATEGORY_PROPERTY);
if (category != null && Boolean.valueOf(category).booleanValue()) {
@ -249,6 +257,7 @@ public class P2MetadataParser implements XMLInputParser {
}
});
addChild(new ProvidesHandler(), new ChildElementHandler<ProvidesHandler>() {
@Override
public void childHanlded(ProvidesHandler child) {
if ("source".equals(child.eclipseType)) {
// this is some source of some bundle
@ -270,10 +279,12 @@ public class P2MetadataParser implements XMLInputParser {
}
});
addChild(new FilterHandler(), new ChildElementHandler<FilterHandler>() {
@Override
public void childHanlded(FilterHandler child) {
}
});
addChild(new RequiresHandler(), new ChildElementHandler<RequiresHandler>() {
@Override
public void childHanlded(RequiresHandler child) {
for (BundleRequirement requirement : child.requirements) {
bundleInfo.addRequirement(requirement);
@ -282,15 +293,18 @@ public class P2MetadataParser implements XMLInputParser {
});
addChild(new HostRequirementsHandler(),
new ChildElementHandler<HostRequirementsHandler>() {
@Override
public void childHanlded(HostRequirementsHandler child) {
}
});
addChild(new MetaRequirementsHandler(),
new ChildElementHandler<MetaRequirementsHandler>() {
@Override
public void childHanlded(MetaRequirementsHandler child) {
}
});
addChild(new ArtifactsHandler(), new ChildElementHandler<ArtifactsHandler>() {
@Override
public void childHanlded(ArtifactsHandler child) {
}
});
@ -299,6 +313,7 @@ public class P2MetadataParser implements XMLInputParser {
// }
// });
addChild(new TouchpointDataHandler(), new ChildElementHandler<TouchpointDataHandler>() {
@Override
public void childHanlded(TouchpointDataHandler child) throws SAXParseException {
if (child.zipped != null) {
bundleInfo.setHasInnerClasspath(child.zipped.booleanValue());
@ -375,6 +390,7 @@ public class P2MetadataParser implements XMLInputParser {
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String id = atts.getValue(ID);
String version = atts.getValue(VERSION);
@ -448,6 +464,7 @@ public class P2MetadataParser implements XMLInputParser {
public ProvidesHandler() {
super(PROVIDES);
addChild(new ProvidedHandler(), new ChildElementHandler<ProvidedHandler>() {
@Override
public void childHanlded(ProvidedHandler child) {
if (child.namespace.equals("org.eclipse.equinox.p2.eclipse.type")) {
eclipseType = child.name;
@ -472,6 +489,7 @@ public class P2MetadataParser implements XMLInputParser {
});
}
@Override
protected void handleAttributes(Attributes atts) {
int size = Integer.parseInt(atts.getValue(SIZE));
capabilities = new ArrayList<BundleCapability>(size);
@ -499,6 +517,7 @@ public class P2MetadataParser implements XMLInputParser {
super(PROVIDED);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
namespace = atts.getValue(NAMESPACE);
name = atts.getValue(NAME);
@ -521,6 +540,7 @@ public class P2MetadataParser implements XMLInputParser {
public AbstractRequirementHandler(String name) {
super(name);
addChild(new RequiredHandler(), new ChildElementHandler<RequiredHandler>() {
@Override
public void childHanlded(RequiredHandler child) {
String name = child.name;
VersionRange range = child.range;
@ -538,6 +558,7 @@ public class P2MetadataParser implements XMLInputParser {
});
}
@Override
protected void handleAttributes(Attributes atts) {
int size = Integer.parseInt(atts.getValue(SIZE));
requirements = new ArrayList<BundleRequirement>(size);
@ -590,6 +611,7 @@ public class P2MetadataParser implements XMLInputParser {
// });
}
@Override
protected void handleAttributes(Attributes atts) throws SAXParseException {
namespace = atts.getValue(NAMESPACE);
name = atts.getValue(NAME);
@ -635,12 +657,14 @@ public class P2MetadataParser implements XMLInputParser {
public ArtifactsHandler() {
super(ARTIFACTS);
addChild(new ArtifactHandler(), new ChildElementHandler<ArtifactHandler>() {
@Override
public void childHanlded(ArtifactHandler child) {
artifacts.add(child.artifact);
}
});
}
@Override
protected void handleAttributes(Attributes atts) {
int size = Integer.parseInt(atts.getValue(SIZE));
artifacts = new ArrayList<P2Artifact>(size);
@ -664,6 +688,7 @@ public class P2MetadataParser implements XMLInputParser {
super(ARTIFACT);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String id = atts.getValue(ID);
String version = atts.getValue(VERSION);
@ -710,6 +735,7 @@ public class P2MetadataParser implements XMLInputParser {
public TouchpointDataHandler() {
super(TOUCHPOINTDATA);
addChild(new InstructionsHandler(), new ChildElementHandler<InstructionsHandler>() {
@Override
public void childHanlded(InstructionsHandler child) {
manifest = child.manifest;
zipped = child.zipped;
@ -717,6 +743,7 @@ public class P2MetadataParser implements XMLInputParser {
});
}
@Override
protected void handleAttributes(Attributes atts) {
// String size = atts.getValue(SIZE);
}
@ -736,6 +763,7 @@ public class P2MetadataParser implements XMLInputParser {
public InstructionsHandler() {
super(INSTRUCTIONS);
addChild(new InstructionHandler(), new ChildElementHandler<InstructionHandler>() {
@Override
public void childHanlded(InstructionHandler child) {
manifest = null;
zipped = null;
@ -749,6 +777,7 @@ public class P2MetadataParser implements XMLInputParser {
});
}
@Override
protected void handleAttributes(Attributes atts) {
// String size = atts.getValue(SIZE);
}
@ -768,6 +797,7 @@ public class P2MetadataParser implements XMLInputParser {
setBufferingChar(true);
}
@Override
protected void handleAttributes(Attributes atts) {
key = atts.getValue(KEY);
}

View File

@ -39,6 +39,7 @@ public class PropertiesParser {
super(PROPERTIES);
final List<String> propList = Arrays.asList(props);
addChild(new PropertyHandler(), new ChildElementHandler<PropertyHandler>() {
@Override
public void childHanlded(PropertyHandler child) {
if (propList.isEmpty() || propList.contains(child.name)) {
properties.put(child.name, child.value);
@ -47,6 +48,7 @@ public class PropertiesParser {
});
}
@Override
protected void handleAttributes(Attributes atts) {
int size = Integer.parseInt(atts.getValue(SIZE));
properties = new HashMap<String, String>(size);
@ -70,6 +72,7 @@ public class PropertiesParser {
super(PROPERTY);
}
@Override
protected void handleAttributes(Attributes atts) {
name = atts.getValue(NAME);
value = atts.getValue(VALUE);

View File

@ -289,6 +289,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
return found;
}
@Override
public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
URL url = artifact.getUrl();
if (url == null) {
@ -313,20 +314,20 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
}
@Override
protected Collection/* <String> */filterNames(Collection/* <String> */names) {
protected Collection<String> filterNames(Collection<String> names) {
getSettings().filterIgnore(names);
return names;
}
@Override
protected Collection findNames(Map tokenValues, String token) {
protected Collection<String> findNames(Map<String, String> tokenValues, String token) {
if (IvyPatternHelper.ORGANISATION_KEY.equals(token)) {
return getRepoDescriptor().getCapabilities();
}
String osgiType = (String) tokenValues.get(IvyPatternHelper.ORGANISATION_KEY);
String osgiType = tokenValues.get(IvyPatternHelper.ORGANISATION_KEY);
if (osgiType == null || osgiType.length() == 0) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
if (IvyPatternHelper.MODULE_KEY.equals(token)) {
@ -334,7 +335,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
}
if (IvyPatternHelper.REVISION_KEY.equals(token)) {
String name = (String) tokenValues.get(IvyPatternHelper.MODULE_KEY);
String name = tokenValues.get(IvyPatternHelper.MODULE_KEY);
List<String> versions = new ArrayList<String>();
Set<ModuleDescriptorWrapper> mds = getRepoDescriptor().findModules(osgiType, name);
if (mds != null) {
@ -346,9 +347,9 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
}
if (IvyPatternHelper.CONF_KEY.equals(token)) {
String name = (String) tokenValues.get(IvyPatternHelper.MODULE_KEY);
String name = tokenValues.get(IvyPatternHelper.MODULE_KEY);
if (name == null) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
if (osgiType.equals(BundleInfo.PACKAGE_TYPE)) {
return Collections.singletonList(BundleInfoAdapter.CONF_USE_PREFIX + name);
@ -356,11 +357,11 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
Collection<ModuleDescriptor> mds = ModuleDescriptorWrapper.unwrap(getRepoDescriptor()
.findModules(osgiType, name));
if (mds == null) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
String version = (String) tokenValues.get(IvyPatternHelper.REVISION_KEY);
String version = tokenValues.get(IvyPatternHelper.REVISION_KEY);
if (version == null) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
ModuleDescriptor found = null;
for (ModuleDescriptor md : mds) {
@ -369,12 +370,12 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
}
}
if (found == null) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
List<String> confs = Arrays.asList(found.getConfigurationsNames());
return confs;
}
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
/**
@ -404,54 +405,62 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
}
@Override
public Map[] listTokenValues(String[] tokens, Map criteria) {
public Map<String, String>[] listTokenValues(String[] tokens, Map<String, Object> criteria) {
Set<String> tokenSet = new HashSet<String>(Arrays.asList(tokens));
Set<Map<String, String>> listTokenValues = listTokenValues(tokenSet, criteria);
return listTokenValues.toArray(new Map[listTokenValues.size()]);
}
private Set<Map<String, String>> listTokenValues(Set<String> tokens,
Map<String, String> criteria) {
Map<String, Object> criteria) {
Map<String, String> stringCriteria = new HashMap<String, String>();
for (Entry<String, Object> entry : criteria.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (!(value instanceof String)) {
// no support for matcher for now
return Collections.emptySet();
}
stringCriteria.put(key, (String) value);
}
if (tokens.isEmpty()) {
return Collections.singleton(criteria);
// no more tokens to resolve
return Collections.singleton(stringCriteria);
}
Set<String> remainingTokens = new HashSet<String>(tokens);
Map<String, String> values = new HashMap<String, String>();
remainingTokens.remove(IvyPatternHelper.ORGANISATION_KEY);
String osgiType = criteria.get(IvyPatternHelper.ORGANISATION_KEY);
if (osgiType == null || osgiType.length() == 0) {
return Collections.emptySet();
}
values.put(IvyPatternHelper.ORGANISATION_KEY, osgiType);
String osgiType = stringCriteria.get(IvyPatternHelper.ORGANISATION_KEY);
if (osgiType == null) {
Set<Map<String, String>> tokenValues = new HashSet<Map<String, String>>();
Map<String, String> newCriteria = new HashMap<String, String>(criteria);
Map<String, Object> newCriteria = new HashMap<String, Object>(criteria);
newCriteria.put(IvyPatternHelper.ORGANISATION_KEY, BundleInfo.BUNDLE_TYPE);
tokenValues.addAll(listTokenValues(remainingTokens, newCriteria));
newCriteria = new HashMap<String, String>(criteria);
newCriteria = new HashMap<String, Object>(criteria);
newCriteria.put(IvyPatternHelper.ORGANISATION_KEY, BundleInfo.PACKAGE_TYPE);
tokenValues.addAll(listTokenValues(remainingTokens, newCriteria));
newCriteria = new HashMap<String, String>(criteria);
newCriteria = new HashMap<String, Object>(criteria);
newCriteria.put(IvyPatternHelper.ORGANISATION_KEY, BundleInfo.SERVICE_TYPE);
tokenValues.addAll(listTokenValues(remainingTokens, newCriteria));
return tokenValues;
}
Map<String, String> values = new HashMap<String, String>();
values.put(IvyPatternHelper.ORGANISATION_KEY, osgiType);
Set<String> capabilities = getRepoDescriptor().getCapabilityValues(osgiType);
if (capabilities == null || capabilities.isEmpty()) {
return Collections.emptySet();
}
remainingTokens.remove(IvyPatternHelper.MODULE_KEY);
String module = criteria.get(IvyPatternHelper.MODULE_KEY);
String module = stringCriteria.get(IvyPatternHelper.MODULE_KEY);
if (module == null) {
Set<Map<String, String>> tokenValues = new HashSet<Map<String, String>>();
for (String name : capabilities) {
Map<String, String> newCriteria = new HashMap<String, String>(criteria);
Map<String, Object> newCriteria = new HashMap<String, Object>(criteria);
newCriteria.put(IvyPatternHelper.MODULE_KEY, name);
tokenValues.addAll(listTokenValues(remainingTokens, newCriteria));
}
@ -460,7 +469,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
values.put(IvyPatternHelper.MODULE_KEY, module);
remainingTokens.remove(IvyPatternHelper.REVISION_KEY);
String rev = criteria.get(IvyPatternHelper.REVISION_KEY);
String rev = stringCriteria.get(IvyPatternHelper.REVISION_KEY);
if (rev == null) {
Set<ModuleDescriptorWrapper> mdws = getRepoDescriptor().findModules(osgiType, module);
if (mdws == null || mdws.isEmpty()) {
@ -468,7 +477,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
}
Set<Map<String, String>> tokenValues = new HashSet<Map<String, String>>();
for (ModuleDescriptorWrapper mdw : mdws) {
Map<String, String> newCriteria = new HashMap<String, String>(criteria);
Map<String, Object> newCriteria = new HashMap<String, Object>(criteria);
newCriteria.put(IvyPatternHelper.REVISION_KEY, mdw.getBundleInfo().getVersion()
.toString());
tokenValues.addAll(listTokenValues(remainingTokens, newCriteria));
@ -478,7 +487,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
values.put(IvyPatternHelper.REVISION_KEY, rev);
remainingTokens.remove(IvyPatternHelper.CONF_KEY);
String conf = criteria.get(IvyPatternHelper.CONF_KEY);
String conf = stringCriteria.get(IvyPatternHelper.CONF_KEY);
if (conf == null) {
if (osgiType.equals(BundleInfo.PACKAGE_TYPE)) {
values.put(IvyPatternHelper.CONF_KEY, BundleInfoAdapter.CONF_USE_PREFIX + module);
@ -508,7 +517,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
List<String> configurations = BundleInfoAdapter
.getConfigurations(found.getBundleInfo());
for (int i = 0; i < configurations.size(); i++) {
Map<String, String> newCriteria = new HashMap<String, String>(criteria);
Map<String, String> newCriteria = new HashMap<String, String>(stringCriteria);
newCriteria.put(IvyPatternHelper.CONF_KEY, configurations.get(i));
tokenValues.add(newCriteria);
}
@ -519,6 +528,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
return Collections.singleton(values);
}
@Override
protected long get(Resource resource, File dest) throws IOException {
Message.verbose("\t" + getName() + ": downloading " + resource.getName());
Message.debug("\t\tto " + dest);
@ -529,6 +539,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
return dest.length();
}
@Override
protected Resource getResource(String source) throws IOException {
return getRepository().getResource(source);
}

View File

@ -34,7 +34,7 @@ import org.xml.sax.SAXException;
public class EclipseUpdateSiteParser {
public static UpdateSite parse(InputStream in) throws ParseException, IOException, SAXException {
public static UpdateSite parse(InputStream in) throws IOException, SAXException {
SiteHandler handler = new SiteHandler();
try {
XMLHelper.parse(in, null, handler, null);
@ -68,6 +68,7 @@ public class EclipseUpdateSiteParser {
// }
// });
addChild(new FeatureHandler(), new ChildElementHandler<FeatureHandler>() {
@Override
public void childHanlded(FeatureHandler child) {
updatesite.addFeature(child.feature);
}
@ -84,6 +85,7 @@ public class EclipseUpdateSiteParser {
// });
}
@Override
protected void handleAttributes(Attributes atts) {
updatesite = new UpdateSite();
@ -170,12 +172,14 @@ public class EclipseUpdateSiteParser {
public FeatureHandler() {
super(FEATURE);
addChild(new CategoryHandler(), new ChildElementHandler<CategoryHandler>() {
@Override
public void childHanlded(CategoryHandler child) {
feature.addCategory(child.name);
}
});
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String id = atts.getValue(ID);
String version = atts.getValue(VERSION);
@ -213,6 +217,7 @@ public class EclipseUpdateSiteParser {
super(CATEGORY);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
name = atts.getValue(NAME);
}

View File

@ -33,8 +33,7 @@ import org.xml.sax.SAXException;
public class FeatureParser {
public static EclipseFeature parse(InputStream in) throws ParseException, IOException,
SAXException {
public static EclipseFeature parse(InputStream in) throws IOException, SAXException {
FeatureHandler handler = new FeatureHandler();
try {
XMLHelper.parse(in, null, handler, null);
@ -81,26 +80,31 @@ public class FeatureParser {
public FeatureHandler() {
super(FEATURE);
addChild(new DescriptionHandler(), new ChildElementHandler<DescriptionHandler>() {
@Override
public void childHanlded(DescriptionHandler child) {
feature.setDescription(child.getBufferedChars().trim());
}
});
addChild(new LicenseHandler(), new ChildElementHandler<LicenseHandler>() {
@Override
public void childHanlded(LicenseHandler child) {
feature.setLicense(child.getBufferedChars().trim());
}
});
addChild(new CopyrightHandler(), new ChildElementHandler<CopyrightHandler>() {
@Override
public void childHanlded(CopyrightHandler child) {
feature.setCopyright(child.getBufferedChars().trim());
}
});
addChild(new PluginHandler(), new ChildElementHandler<PluginHandler>() {
@Override
public void childHanlded(PluginHandler child) {
feature.addPlugin(child.plugin);
}
});
addChild(new RequiresHandler(), new ChildElementHandler<RequiresHandler>() {
@Override
public void childHanlded(RequiresHandler child) {
for (Require require : child.requires) {
feature.addRequire(require);
@ -113,6 +117,7 @@ public class FeatureParser {
// });
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
String id = atts.getValue(ID);
String version = atts.getValue(VERSION);
@ -159,6 +164,7 @@ public class FeatureParser {
super(PLUGIN);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
plugin = new EclipsePlugin();
@ -189,6 +195,7 @@ public class FeatureParser {
setBufferingChar(true);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
// String url = atts.getValue(URL);
}
@ -205,6 +212,7 @@ public class FeatureParser {
setBufferingChar(true);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
// String url = atts.getValue(URL);
}
@ -222,6 +230,7 @@ public class FeatureParser {
setBufferingChar(true);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
// String url = atts.getValue(URL);
}
@ -236,6 +245,7 @@ public class FeatureParser {
public RequiresHandler() {
super(REQUIRES);
addChild(new ImportHandler(), new ChildElementHandler<ImportHandler>() {
@Override
public void childHanlded(ImportHandler child) {
requires.add(child.require);
}
@ -263,6 +273,7 @@ public class FeatureParser {
super(IMPORT);
}
@Override
protected void handleAttributes(Attributes atts) throws SAXException {
require = new Require();

View File

@ -19,7 +19,6 @@ package org.apache.ivy.osgi.updatesite.xml;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import javax.xml.parsers.ParserConfigurationException;
@ -32,8 +31,8 @@ import org.xml.sax.SAXException;
public class UpdateSiteDigestParser {
public static UpdateSiteDescriptor parse(InputStream in, UpdateSite site)
throws ParseException, IOException, SAXException {
public static UpdateSiteDescriptor parse(InputStream in, UpdateSite site) throws IOException,
SAXException {
DigestHandler handler = new DigestHandler(site);
try {
XMLHelper.parse(in, null, handler, null);
@ -54,6 +53,7 @@ public class UpdateSiteDigestParser {
repoDescriptor = new UpdateSiteDescriptor(site.getUri(),
ExecutionEnvironmentProfileProvider.getInstance());
addChild(new FeatureHandler(), new ChildElementHandler<FeatureHandler>() {
@Override
public void childHanlded(FeatureHandler child) {
repoDescriptor.addFeature(child.feature);
}

View File

@ -92,6 +92,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
return charBuffer.toString();
}
@Override
public void setDocumentLocator(Locator locator) {
this.locator = locator;
for (DelegatingHandler subHandler : saxHandlerMapping.values()) {
@ -146,6 +147,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
}
}
@Override
public final void startDocument() throws SAXException {
if (skip) {
return;
@ -164,6 +166,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void endDocument() throws SAXException {
if (skip) {
return;
@ -182,6 +185,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void startElement(final String uri, final String localName, final String n,
final Attributes atts) throws SAXException {
// reset the char buffer
@ -246,6 +250,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void endElement(final String uri, final String localName, final String n)
throws SAXException {
if (delegate != null) {
@ -297,6 +302,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
}
@Override
public final void characters(char[] ch, int start, int length) throws SAXException {
if (skip) {
return;
@ -317,6 +323,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
}
}
@Override
public final void startPrefixMapping(String prefix, String uri) throws SAXException {
if (skip) {
return;
@ -335,6 +342,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void endPrefixMapping(String prefix) throws SAXException {
if (skip) {
return;
@ -353,6 +361,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
if (skip) {
return;
@ -371,6 +380,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void notationDecl(String name, String publicId, String systemId)
throws SAXException {
if (skip) {
@ -391,6 +401,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void processingInstruction(String target, String data) throws SAXException {
if (skip) {
return;
@ -409,6 +420,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void skippedEntity(String name) throws SAXException {
if (skip) {
return;
@ -427,9 +439,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
/**
* @throws SAXException
*/
@Override
public final void unparsedEntityDecl(String name, String publicId, String systemId,
String notationName) throws SAXException {
if (skip) {
@ -452,6 +462,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// ERROR HANDLING
@Override
public final void warning(SAXParseException exception) throws SAXException {
if (skip) {
return;
@ -470,6 +481,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void error(SAXParseException exception) throws SAXException {
if (skip) {
return;
@ -488,6 +500,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
// by default do nothing
}
@Override
public final void fatalError(SAXParseException exception) throws SAXException {
if (skip) {
return;

View File

@ -20,6 +20,7 @@ package org.apache.ivy.plugins.conflict;
import java.util.Collection;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.IvySettingsAware;
@ -44,10 +45,12 @@ public abstract class AbstractConflictManager implements ConflictManager, IvySet
this.name = name;
}
@Override
public String toString() {
return name;
}
public void handleAllBlacklistedRevisions(DependencyDescriptor dd, Collection foundBlacklisted) {
public void handleAllBlacklistedRevisions(DependencyDescriptor dd,
Collection<ModuleRevisionId> foundBlacklisted) {
}
}

View File

@ -20,6 +20,7 @@ package org.apache.ivy.plugins.conflict;
import java.util.Collection;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.resolve.IvyNode;
public interface ConflictManager {
@ -38,7 +39,7 @@ public interface ConflictManager {
* @return a Collection of IvyNode which have not been evicted, or null if conflict management
* resolution is not possible yet
*/
Collection resolveConflicts(IvyNode parent, Collection conflicts);
Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts);
String getName();
@ -56,5 +57,5 @@ public interface ConflictManager {
* the list of all ModuleRevisionId found which are blacklisted
*/
void handleAllBlacklistedRevisions(DependencyDescriptor dd,
Collection/* <ModuleRevisionId> */foundBlacklisted);
Collection<ModuleRevisionId> foundBlacklisted);
}

View File

@ -20,22 +20,21 @@ package org.apache.ivy.plugins.conflict;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import org.apache.ivy.core.resolve.IvyNode;
public class FixedConflictManager extends AbstractConflictManager {
private Collection revisions;
private Collection<String> revisions;
public FixedConflictManager(String[] revs) {
revisions = Arrays.asList(revs);
setName("fixed" + revisions);
}
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();
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) {
Collection<IvyNode> resolved = new ArrayList<IvyNode>(conflicts.size());
for (IvyNode node : conflicts) {
String revision = node.getResolvedId().getRevision();
if (revisions.contains(revision)) {
resolved.add(node);
@ -44,7 +43,7 @@ public class FixedConflictManager extends AbstractConflictManager {
return resolved;
}
public Collection getRevs() {
public Collection<String> getRevs() {
return revisions;
}

View File

@ -71,19 +71,20 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
super(name, strategy);
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
@Override
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) {
if (conflicts.size() < 2) {
return conflicts;
}
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
Iterator iter = conflicts.iterator();
IvyNode node = (IvyNode) iter.next();
Iterator<IvyNode> iter = conflicts.iterator();
IvyNode node = iter.next();
ModuleRevisionId mrid = node.getResolvedId();
if (versionMatcher.isDynamic(mrid)) {
while (iter.hasNext()) {
IvyNode other = (IvyNode) iter.next();
IvyNode other = iter.next();
if (versionMatcher.isDynamic(other.getResolvedId())) {
// two dynamic versions in conflict, not enough information yet
return null;
@ -98,17 +99,17 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
if (conflicts.size() == 2) {
// very common special case of only two modules in conflict,
// let's return the second one (static)
Iterator it = conflicts.iterator();
Iterator<IvyNode> it = conflicts.iterator();
it.next();
return Collections.singleton(it.next());
}
Collection newConflicts = new LinkedHashSet(conflicts);
Collection<IvyNode> newConflicts = new LinkedHashSet<IvyNode>(conflicts);
newConflicts.remove(node);
return super.resolveConflicts(parent, newConflicts);
} else {
// the first node is a static revision, let's see if all other versions match
while (iter.hasNext()) {
IvyNode other = (IvyNode) iter.next();
IvyNode other = iter.next();
if (!versionMatcher.accept(other.getResolvedId(), mrid)) {
// incompatibility found
if (!handleIncompatibleConflict(parent, conflicts, node, other)) {
@ -152,8 +153,8 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
* @return true if the incompatible conflict has been handled, false otherwise (in which case
* resolveConflicts should return null)
*/
private boolean handleIncompatibleConflict(IvyNode parent, Collection conflicts, IvyNode node,
IvyNode other) {
private boolean handleIncompatibleConflict(IvyNode parent, Collection<IvyNode> conflicts,
IvyNode node, IvyNode other) {
// we never actually return anything else than false or throw an exception,
// but returning a boolean make the calling code cleaner
try {
@ -184,14 +185,14 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
private void blackListIncompatibleCallerAndRestartResolveIfPossible(IvySettings settings,
IvyNode parent, IvyNode selected, IvyNode evicted) {
Stack callerStack = new Stack();
Stack<IvyNode> callerStack = new Stack<IvyNode>();
callerStack.push(evicted);
final Collection toBlacklist = blackListIncompatibleCaller(settings.getVersionMatcher(),
parent, selected, evicted, callerStack);
Collection<IvyNodeBlacklist> toBlacklist = blackListIncompatibleCaller(
settings.getVersionMatcher(), parent, selected, evicted, callerStack);
if (toBlacklist != null) {
final StringBuffer blacklisted = new StringBuffer();
for (Iterator iterator = toBlacklist.iterator(); iterator.hasNext();) {
IvyNodeBlacklist blacklist = (IvyNodeBlacklist) iterator.next();
for (Iterator<IvyNodeBlacklist> iterator = toBlacklist.iterator(); iterator.hasNext();) {
IvyNodeBlacklist blacklist = iterator.next();
blacklist.getBlacklistedNode().blacklist(blacklist);
blacklisted.append(blacklist.getBlacklistedNode());
if (iterator.hasNext()) {
@ -212,9 +213,9 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
}
}
private boolean handleIncompatibleCaller(Stack callerStack, IvyNode node, IvyNode callerNode,
IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode,
Collection blacklisted, VersionMatcher versionMatcher) {
private boolean handleIncompatibleCaller(Stack<IvyNode> callerStack, IvyNode node,
IvyNode callerNode, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode,
Collection<IvyNodeBlacklist> blacklisted, VersionMatcher versionMatcher) {
if (callerStack.subList(0, callerStack.size() - 1).contains(node)) {
// circular dependency found and handled: the current top of the stack (node)
// was already contained in the rest of the stack, the circle is closed, nothing
@ -222,8 +223,8 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
return true;
} else {
callerStack.push(callerNode);
Collection sub = blackListIncompatibleCaller(versionMatcher, conflictParent,
selectedNode, evictedNode, callerStack);
Collection<IvyNodeBlacklist> sub = blackListIncompatibleCaller(versionMatcher,
conflictParent, selectedNode, evictedNode, callerStack);
callerStack.pop();
if (sub == null) {
// propagate the fact that a path with unblacklistable caller has been found
@ -251,11 +252,11 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
* @return the collection of blacklisting to do, null if a blacklist is not possible in at least
* one caller path
*/
private Collection/* <IvyNodeBlacklist> */blackListIncompatibleCaller(
VersionMatcher versionMatcher, IvyNode conflictParent, IvyNode selectedNode,
IvyNode evictedNode, Stack/* <IvyNode> */callerStack) {
Collection/* <IvyNodeBlacklist> */blacklisted = new ArrayList/* <IvyNodeBlacklist> */();
IvyNode node = (IvyNode) callerStack.peek();
private Collection<IvyNodeBlacklist> blackListIncompatibleCaller(VersionMatcher versionMatcher,
IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode,
Stack<IvyNode> callerStack) {
Collection<IvyNodeBlacklist> blacklisted = new ArrayList<IvyNodeBlacklist>();
IvyNode node = callerStack.peek();
String rootModuleConf = conflictParent.getData().getReport().getConfiguration();
Caller[] callers = node.getCallers(rootModuleConf);
for (int i = 0; i < callers.length; i++) {
@ -282,30 +283,30 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
return blacklisted;
}
protected void handleUnsolvableConflict(IvyNode parent, Collection conflicts, IvyNode node1,
IvyNode node2) {
protected void handleUnsolvableConflict(IvyNode parent, Collection<IvyNode> conflicts,
IvyNode node1, IvyNode node2) {
throw new StrictConflictException(node1, node2);
}
@Override
public void handleAllBlacklistedRevisions(DependencyDescriptor dd,
Collection/* <ModuleRevisionId> */foundBlacklisted) {
Collection<ModuleRevisionId> foundBlacklisted) {
ResolveData resolveData = IvyContext.getContext().getResolveData();
Collection/* <IvyNode> */blacklisted = new HashSet();
for (Iterator iterator = foundBlacklisted.iterator(); iterator.hasNext();) {
ModuleRevisionId mrid = (ModuleRevisionId) iterator.next();
Collection<IvyNode> blacklisted = new HashSet<IvyNode>();
for (ModuleRevisionId mrid : foundBlacklisted) {
blacklisted.add(resolveData.getNode(mrid));
}
for (Iterator iterator = blacklisted.iterator(); iterator.hasNext();) {
IvyNode node = (IvyNode) iterator.next();
for (IvyNode node : blacklisted) {
IvyNodeBlacklist bdata = node.getBlacklistData(resolveData.getReport()
.getConfiguration());
handleUnsolvableConflict(bdata.getConflictParent(),
Arrays.asList(new Object[] {bdata.getEvictedNode(), bdata.getSelectedNode()}),
Arrays.asList(bdata.getEvictedNode(), bdata.getSelectedNode()),
bdata.getEvictedNode(), bdata.getSelectedNode());
}
}
@Override
public String toString() {
return getName();
}

View File

@ -20,7 +20,6 @@ package org.apache.ivy.plugins.conflict;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
@ -78,12 +77,11 @@ public class LatestConflictManager extends AbstractConflictManager {
this.strategy = strategy;
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) {
if (conflicts.size() < 2) {
return conflicts;
}
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
for (IvyNode node : conflicts) {
DependencyDescriptor dd = node.getDependencyDescriptor(parent);
if (dd != null && dd.isForce()
&& parent.getResolvedId().equals(dd.getParentRevisionId())) {
@ -95,17 +93,15 @@ public class LatestConflictManager extends AbstractConflictManager {
* If the list of conflicts contains dynamic revisions, delay the conflict calculation until
* they are resolved. TODO: we probably could already evict some of the dynamic revisions!
*/
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
for (IvyNode node : conflicts) {
ModuleRevisionId modRev = node.getResolvedId();
if (getSettings().getVersionMatcher().isDynamic(modRev)) {
return null;
}
}
ArrayList unevicted = new ArrayList();
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
ArrayList<IvyNode> unevicted = new ArrayList<IvyNode>();
for (IvyNode node : conflicts) {
if (!node.isCompletelyEvicted())
unevicted.add(node);
}
@ -128,13 +124,12 @@ public class LatestConflictManager extends AbstractConflictManager {
}
}
protected ArtifactInfo[] toArtifactInfo(Collection conflicts) {
List artifacts = new ArrayList(conflicts.size());
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
protected ArtifactInfo[] toArtifactInfo(Collection<IvyNode> conflicts) {
List<ArtifactInfo> artifacts = new ArrayList<ArtifactInfo>(conflicts.size());
for (IvyNode node : conflicts) {
artifacts.add(new IvyNodeArtifactInfo(node));
}
return (ArtifactInfo[]) artifacts.toArray(new ArtifactInfo[artifacts.size()]);
return artifacts.toArray(new ArtifactInfo[artifacts.size()]);
}
public LatestStrategy getStrategy() {
@ -165,6 +160,7 @@ public class LatestConflictManager extends AbstractConflictManager {
this.strategy = strategy;
}
@Override
public String toString() {
return strategy != null ? String.valueOf(strategy) : strategyName;
}

View File

@ -26,7 +26,7 @@ public class NoConflictManager extends AbstractConflictManager {
setName("all");
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) {
return conflicts;
}
}

View File

@ -20,7 +20,6 @@ package org.apache.ivy.plugins.conflict;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -66,10 +65,9 @@ public class RegexpConflictManager extends AbstractConflictManager {
mIgnoreNonMatching = ignoreNonMatching;
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) {
IvyNode lastNode = null;
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
for (IvyNode node : conflicts) {
if (lastNode != null && !matchEquals(node, lastNode)) {
String msg = lastNode + ":" + getMatch(lastNode) + " (needed by "

View File

@ -19,7 +19,6 @@ package org.apache.ivy.plugins.conflict;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.plugins.version.VersionMatcher;
@ -29,13 +28,11 @@ public class StrictConflictManager extends AbstractConflictManager {
public StrictConflictManager() {
}
public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) {
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
IvyNode lastNode = null;
for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
IvyNode node = (IvyNode) iter.next();
for (IvyNode node : conflicts) {
if (versionMatcher.isDynamic(node.getResolvedId())) {
// dynamic revision, not enough information to resolve conflict
return null;

View File

@ -32,17 +32,18 @@ public abstract class AbstractLatestStrategy implements LatestStrategy {
this.name = name;
}
@Override
public String toString() {
return name;
}
public ArtifactInfo findLatest(ArtifactInfo[] infos, Date date) {
List l = sort(infos);
List<ArtifactInfo> l = sort(infos);
// the latest revision comes last, use a ListIterator to iterate the
// sorted list in the reverse direction.
for (ListIterator iter = l.listIterator(l.size()); iter.hasPrevious();) {
ArtifactInfo info = (ArtifactInfo) iter.previous();
for (ListIterator<ArtifactInfo> iter = l.listIterator(l.size()); iter.hasPrevious();) {
ArtifactInfo info = iter.previous();
if (date == null || info.getLastModified() < date.getTime()) {
return info;
}

View File

@ -25,26 +25,26 @@ import java.util.List;
public class ComparatorLatestStrategy extends AbstractLatestStrategy {
private Comparator comparator;
private Comparator<ArtifactInfo> comparator;
public ComparatorLatestStrategy() {
}
public ComparatorLatestStrategy(Comparator comparator) {
public ComparatorLatestStrategy(Comparator<ArtifactInfo> comparator) {
this.comparator = comparator;
}
public List sort(ArtifactInfo[] infos) {
List ret = new ArrayList(Arrays.asList(infos));
public List<ArtifactInfo> sort(ArtifactInfo[] infos) {
List<ArtifactInfo> ret = new ArrayList<ArtifactInfo>(Arrays.asList(infos));
Collections.sort(ret, comparator);
return ret;
}
public Comparator getComparator() {
public Comparator<ArtifactInfo> getComparator() {
return comparator;
}
public void setComparator(Comparator comparator) {
public void setComparator(Comparator<ArtifactInfo> comparator) {
this.comparator = comparator;
}

View File

@ -26,10 +26,10 @@ public class LatestLexicographicStrategy extends ComparatorLatestStrategy {
* 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 final Comparator COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
String rev1 = ((ArtifactInfo) o1).getRevision();
String rev2 = ((ArtifactInfo) o2).getRevision();
private static final Comparator<ArtifactInfo> COMPARATOR = new Comparator<ArtifactInfo>() {
public int compare(ArtifactInfo o1, ArtifactInfo o2) {
String rev1 = o1.getRevision();
String rev2 = o2.getRevision();
if (rev1.startsWith("latest")) {
return 1;
}

View File

@ -31,10 +31,10 @@ public class LatestRevisionStrategy extends ComparatorLatestStrategy {
* Compares two ModuleRevisionId by their revision. Revisions are compared using an algorithm
* inspired by PHP version_compare one.
*/
final class MridComparator implements Comparator {
public int compare(Object o1, Object o2) {
String rev1 = ((ModuleRevisionId) o1).getRevision();
String rev2 = ((ModuleRevisionId) o2).getRevision();
final class MridComparator implements Comparator<ModuleRevisionId> {
public int compare(ModuleRevisionId o1, ModuleRevisionId o2) {
String rev1 = o1.getRevision();
String rev2 = o2.getRevision();
rev1 = rev1.replaceAll("([a-zA-Z])(\\d)", "$1.$2");
rev1 = rev1.replaceAll("(\\d)([a-zA-Z])", "$1.$2");
@ -61,9 +61,9 @@ public class LatestRevisionStrategy extends ComparatorLatestStrategy {
return Long.valueOf(parts1[i]).compareTo(Long.valueOf(parts2[i]));
}
// both are strings, we compare them taking into account special meaning
Map specialMeanings = getSpecialMeanings();
Integer sm1 = (Integer) specialMeanings.get(parts1[i].toLowerCase(Locale.US));
Integer sm2 = (Integer) specialMeanings.get(parts2[i].toLowerCase(Locale.US));
Map<String, Integer> specialMeanings = getSpecialMeanings();
Integer sm1 = specialMeanings.get(parts1[i].toLowerCase(Locale.US));
Integer sm2 = specialMeanings.get(parts2[i].toLowerCase(Locale.US));
if (sm1 != null) {
sm2 = sm2 == null ? new Integer(0) : sm2;
return sm1.compareTo(sm2);
@ -92,10 +92,10 @@ public class LatestRevisionStrategy extends ComparatorLatestStrategy {
* inspired by PHP version_compare one, unless a dynamic revision is given, in which case the
* version matcher is used to perform the comparison.
*/
final class ArtifactInfoComparator implements Comparator {
public int compare(Object o1, Object o2) {
String rev1 = ((ArtifactInfo) o1).getRevision();
String rev2 = ((ArtifactInfo) o2).getRevision();
final class ArtifactInfoComparator implements Comparator<ArtifactInfo> {
public int compare(ArtifactInfo o1, ArtifactInfo o2) {
String rev1 = o1.getRevision();
String rev2 = o2.getRevision();
/*
* The revisions can still be not resolved, so we use the current version matcher to
@ -152,19 +152,19 @@ public class LatestRevisionStrategy extends ComparatorLatestStrategy {
}
}
private static final Map DEFAULT_SPECIAL_MEANINGS;
private static final Map<String, Integer> DEFAULT_SPECIAL_MEANINGS;
static {
DEFAULT_SPECIAL_MEANINGS = new HashMap();
DEFAULT_SPECIAL_MEANINGS = new HashMap<String, Integer>();
DEFAULT_SPECIAL_MEANINGS.put("dev", new Integer(-1));
DEFAULT_SPECIAL_MEANINGS.put("rc", new Integer(1));
DEFAULT_SPECIAL_MEANINGS.put("final", new Integer(2));
}
private final Comparator mridComparator = new MridComparator();
private final Comparator<ModuleRevisionId> mridComparator = new MridComparator();
private final Comparator artifactInfoComparator = new ArtifactInfoComparator();
private final Comparator<ArtifactInfo> artifactInfoComparator = new ArtifactInfoComparator();
private Map specialMeanings = null;
private Map<String, Integer> specialMeanings = null;
private boolean usedefaultspecialmeanings = true;
@ -178,9 +178,9 @@ public class LatestRevisionStrategy extends ComparatorLatestStrategy {
getSpecialMeanings().put(meaning.getName().toLowerCase(Locale.US), meaning.getValue());
}
public synchronized Map getSpecialMeanings() {
public synchronized Map<String, Integer> getSpecialMeanings() {
if (specialMeanings == null) {
specialMeanings = new HashMap();
specialMeanings = new HashMap<String, Integer>();
if (isUsedefaultspecialmeanings()) {
specialMeanings.putAll(DEFAULT_SPECIAL_MEANINGS);
}

View File

@ -39,7 +39,7 @@ public interface LatestStrategy {
* @param infos
* @return
*/
List sort(ArtifactInfo[] infos);
List<ArtifactInfo> sort(ArtifactInfo[] infos);
String getName();
}

View File

@ -20,10 +20,10 @@ package org.apache.ivy.plugins.latest;
import java.util.Comparator;
public class LatestTimeStrategy extends ComparatorLatestStrategy {
private static final Comparator COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
long d1 = ((ArtifactInfo) o1).getLastModified();
long d2 = ((ArtifactInfo) o2).getLastModified();
private static final Comparator<ArtifactInfo> COMPARATOR = new Comparator<ArtifactInfo>() {
public int compare(ArtifactInfo o1, ArtifactInfo o2) {
long d1 = o1.getLastModified();
long d2 = o2.getLastModified();
return new Long(d1).compareTo(new Long(d2));
}

View File

@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.ivy.plugins.latest;
import java.util.ArrayList;
import java.util.List;
/**
* A strategy which delegate to another strategy, unless for the latest and working revisions which
* are considered as superior to any other revision. < br/>
* NB : it is for internal usage of Ivy only!
*/
public class WorkspaceLatestStrategy extends AbstractLatestStrategy {
private LatestStrategy delegate;
public WorkspaceLatestStrategy(LatestStrategy delegate) {
this.delegate = delegate;
setName("workspace-" + delegate.getName());
}
public List<ArtifactInfo> sort(ArtifactInfo[] infos) {
List<ArtifactInfo> sorted = delegate.sort(infos);
List<ArtifactInfo> head = new ArrayList<ArtifactInfo>();
List<ArtifactInfo> tail = new ArrayList<ArtifactInfo>();
for (ArtifactInfo ai : sorted) {
String rev = ai.getRevision();
boolean latestRev = rev.startsWith("latest") || rev.startsWith("working");
if (latestRev) {
head.add(ai);
} else {
tail.add(ai);
}
}
head.addAll(tail);
return head;
}
}

View File

@ -57,6 +57,7 @@ public abstract class AbstractPatternMatcher implements PatternMatcher {
*/
protected abstract/* @NotNull */Matcher newMatcher(/* @NotNull */String expression);
@Override
public String toString() {
return getName();
}

View File

@ -36,6 +36,7 @@ public/* @Immutable */final class ExactOrRegexpPatternMatcher extends AbstractPa
super(EXACT_OR_REGEXP);
}
@Override
protected Matcher newMatcher(String expression) {
return new ExactOrRegexpMatcher(expression);
}

View File

@ -31,6 +31,7 @@ public/* @Immutable */final class ExactPatternMatcher extends AbstractPatternMat
super(EXACT);
}
@Override
protected Matcher newMatcher(String expression) {
return new ExactMatcher(expression);
}

View File

@ -51,6 +51,7 @@ public/* @Immutable */final class GlobPatternMatcher extends AbstractPatternMatc
super(GLOB);
}
@Override
protected Matcher newMatcher(String expression) {
return new GlobMatcher(expression);
}

View File

@ -19,35 +19,31 @@ package org.apache.ivy.plugins.matcher;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class MapMatcher {
private Map/* <String, Matcher> */matchers = new HashMap();
private Map<String, Matcher> matchers = new HashMap<String, Matcher>();
private PatternMatcher pm;
private Map attributes;
private Map<String, String> attributes;
public MapMatcher(Map attributes, PatternMatcher pm) {
public MapMatcher(Map<String, String> attributes, PatternMatcher pm) {
this.attributes = attributes;
this.pm = pm;
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
Entry entry = (Entry) iter.next();
String value = (String) entry.getValue();
for (Entry<String, String> entry : attributes.entrySet()) {
String value = entry.getValue();
if (value != null) {
matchers.put(entry.getKey(), pm.getMatcher(value));
}
}
}
public boolean matches(Map/* <String,String> */m) {
for (Iterator iter = matchers.entrySet().iterator(); iter.hasNext();) {
Entry entry = (Entry) iter.next();
Matcher matcher = (Matcher) entry.getValue();
String value = (String) m.get(entry.getKey());
public boolean matches(Map<String, String> m) {
for (Entry<String, Matcher> entry : matchers.entrySet()) {
Matcher matcher = entry.getValue();
String value = m.get(entry.getKey());
if ((value == null) || !matcher.matches(value)) {
return false;
}
@ -56,11 +52,12 @@ public class MapMatcher {
return true;
}
@Override
public String toString() {
return attributes + " (" + pm.getName() + ")";
}
public Map getAttributes() {
public Map<String, String> getAttributes() {
return Collections.unmodifiableMap(attributes);
}

View File

@ -38,6 +38,7 @@ public final/* @Immutable */class RegexpPatternMatcher extends AbstractPatternMa
super(REGEXP);
}
@Override
protected Matcher newMatcher(String expression) {
return new RegexpMatcher(expression);
}

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