Complete generification of examples; update example dependencies; use Java 7 syntax in test; fix regression in ModuleIdTest
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/fb3ccf60 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/fb3ccf60 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/fb3ccf60 Branch: refs/heads/master Commit: fb3ccf60e9a2d55a1abe8aafe38e45861e7a8eac Parents: 314dfa8 Author: twogee <g.grigelio...@gmail.com> Authored: Tue Jun 13 19:35:37 2017 +0200 Committer: twogee <g.grigelio...@gmail.com> Committed: Tue Jun 13 19:35:37 2017 +0200 ---------------------------------------------------------------------- src/example/bintray/ivy.xml | 10 ++-- .../chainedresolvers-project/ivy.xml | 4 +- src/example/configurations/jdbc-example/ivy.xml | 32 ++++++------- .../src/example/ConfigurationsExample.java | 9 ++-- .../multi-projects/filter-framework/ivy.xml | 18 +++---- .../src/filter/FilterProvider.java | 4 +- .../src/filter/ccimpl/CCFilter.java | 12 ++--- .../src/filter/hmimpl/HMFilter.java | 8 ++-- .../configurations/multi-projects/myapp/ivy.xml | 12 ++--- src/example/dependence/dependee/ivy.xml | 4 +- src/example/dependence/depender/ivy.xml | 4 +- src/example/dual/project/ivy.xml | 4 +- .../dual/project/src/example/HelloIvy.java | 4 +- src/example/hello-ivy/ivy.xml | 6 +-- .../hello-ivy/src/example/HelloConsole.java | 14 +++--- .../multi-project/projects/console/ivy.xml | 12 ++--- .../projects/console/src/console/Main.java | 10 ++-- src/example/multi-project/projects/find/ivy.xml | 14 +++--- .../projects/find/src/find/FindFile.java | 24 +++++----- .../projects/find/src/find/Main.java | 34 +++++++------- src/example/multi-project/projects/list/ivy.xml | 10 ++-- .../projects/list/src/list/ListFile.java | 11 +++-- .../projects/list/src/list/Main.java | 18 ++++--- src/example/multi-project/projects/size/ivy.xml | 8 ++-- .../projects/size/src/size/FileSize.java | 18 +++---- .../multi-project/projects/sizewhere/ivy.xml | 14 +++--- .../projects/sizewhere/src/sizewhere/Main.java | 32 ++++++------- .../sizewhere/src/sizewhere/SizeWhere.java | 9 ++-- .../multi-project/projects/version/ivy.xml | 4 +- .../projects/version/src/version/Version.java | 4 +- .../org/apache/ivy/ant/AntCallTriggerTest.java | 5 +- .../org/apache/ivy/ant/BuildOBRTaskTest.java | 5 +- .../org/apache/ivy/ant/FixDepsTaskTest.java | 2 +- .../java/org/apache/ivy/ant/IvyDeliverTest.java | 49 +++++++++----------- .../apache/ivy/core/module/id/ModuleIdTest.java | 1 + 35 files changed, 211 insertions(+), 218 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/bintray/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/bintray/ivy.xml b/src/example/bintray/ivy.xml index 120a43b..9b9721c 100644 --- a/src/example/bintray/ivy.xml +++ b/src/example/bintray/ivy.xml @@ -20,12 +20,12 @@ <info organisation="org.apache" module="hello-ivy"/> <dependencies> <!-- https://jcenter.bintray.com/ --> - <dependency org="org.jfrog.artifactory.client" name="artifactory-cli" rev="1.0" /> - <dependency org="org.jfrog.artifactory.client" name="artifactory-cli" rev="1.0" /> - <dependency org="org.jfrog" name="build-info-api" rev="1.3.1" /> + <dependency org="org.jfrog.artifactory.client" name="artifactory-cli" rev="1.0"/> + <dependency org="org.jfrog.artifactory.client" name="artifactory-cli" rev="1.0"/> + <dependency org="org.jfrog" name="build-info-api" rev="1.3.1"/> <!-- https://dl.bintray.com/dsowerby/maven/ --> - <dependency org="uk.q3c.krail" name="krail" rev="0.7.0" /> + <dependency org="uk.q3c.krail" name="krail" rev="0.7.0"/> <!-- https://dl.bintray.com/igelgrun/batrak/ --> - <dependency org="igel.batrak" name="batrak-core" rev="0.1" /> + <dependency org="igel.batrak" name="batrak-core" rev="0.1"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/chained-resolvers/chainedresolvers-project/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/chained-resolvers/chainedresolvers-project/ivy.xml b/src/example/chained-resolvers/chainedresolvers-project/ivy.xml index 450d0a6..5509889 100644 --- a/src/example/chained-resolvers/chainedresolvers-project/ivy.xml +++ b/src/example/chained-resolvers/chainedresolvers-project/ivy.xml @@ -14,12 +14,12 @@ "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. --> <ivy-module version="1.0"> <info organisation="org.apache" module="chained-resolvers"/> <dependencies> - <dependency org="commons-lang" name="commons-lang" rev="2.0" conf="default"/> + <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="default"/> <dependency name="test" rev="1.0"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/configurations/jdbc-example/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/configurations/jdbc-example/ivy.xml b/src/example/configurations/jdbc-example/ivy.xml index 8e42350..ee8a82c 100644 --- a/src/example/configurations/jdbc-example/ivy.xml +++ b/src/example/configurations/jdbc-example/ivy.xml @@ -15,30 +15,30 @@ "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. --> <ivy-module version="1.0"> <info organisation="org.apache" module="configurations" > - <description> - This is an example project that aims to demonstrate the usage of the configuration in ivy. - This project provide 4 configurations. Each configurations describe the requirement to build or run the project - </description> + <description> + This is an example project that aims to demonstrate the usage of the configuration in ivy. + This project provide 4 configurations. Each configurations describe the requirement to build or run the project + </description> </info> <configurations> - <conf name="compile" description="This is this configuration that describes modules need to build our project"/> - <conf name="test" extends="compile" description="This is this configuration that describes modules need to run test on our project"/> - <conf name="rundev" extends="compile" description="This is this configuration that describes modules need to execute our project in a dev environement"/> - <conf name="runprod" extends="compile" description="This is this configuration that describes modules need to execute our project in a production environement"/> + <conf name="compile" description="This is this configuration that describes modules need to build our project"/> + <conf name="test" extends="compile" description="This is this configuration that describes modules need to run test on our project"/> + <conf name="rundev" extends="compile" description="This is this configuration that describes modules need to execute our project in a dev environement"/> + <conf name="runprod" extends="compile" description="This is this configuration that describes modules need to execute our project in a production environement"/> </configurations> - + <dependencies> - <!-- this dependency is needed for all configuration --> - <dependency org="commons-cli" name="commons-cli" rev="1.0" /> + <!-- this dependency is needed for all configuration --> + <dependency org="commons-cli" name="commons-cli" rev="1.4"/> <!-- when launching our app in dev mode we use mckoi db and mckoi jdbc client conf="run.dev->embedded, client"--> - <dependency org="mckoi" name="mckoi" rev="1.0.2" conf="rundev->default"/> + <dependency org="mckoi" name="mckoi" rev="1.0.2" conf="rundev->default"/> <!-- when launching our app in production environement we needs other jdbc driver --> - <dependency org="mm-mysql" name="mm-mysql" rev="2.0.7" conf="runprod->default"/> - <!-- junit is only need in the test configuration--> - <dependency org="junit" name="junit" rev="4.12" conf="test->default"/> + <dependency org="mm-mysql" name="mm-mysql" rev="2.0.7" conf="runprod->default"/> + <!-- junit is only need in the test configuration--> + <dependency org="junit" name="junit" rev="4.12" conf="test->default"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/configurations/jdbc-example/src/example/ConfigurationsExample.java ---------------------------------------------------------------------- diff --git a/src/example/configurations/jdbc-example/src/example/ConfigurationsExample.java b/src/example/configurations/jdbc-example/src/example/ConfigurationsExample.java index 925824f..0a6a0e6 100644 --- a/src/example/configurations/jdbc-example/src/example/ConfigurationsExample.java +++ b/src/example/configurations/jdbc-example/src/example/ConfigurationsExample.java @@ -17,19 +17,20 @@ */ package example; -import java.io.IOException; -import java.util.Properties; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; -import org.apache.commons.cli.PosixParser; + +import java.io.IOException; +import java.util.Properties; public final class ConfigurationsExample { public static void main(String[] args) { String jdbcPropToLoad = "prod.properties"; - CommandLineParser parser = new PosixParser(); + CommandLineParser parser = new DefaultParser(); Options options = new Options(); options.addOption("d", "dev", false, "Dev tag to launch app in dev mode. Means that app will launch embedded mckoi db."); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/configurations/multi-projects/filter-framework/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/configurations/multi-projects/filter-framework/ivy.xml b/src/example/configurations/multi-projects/filter-framework/ivy.xml index fc5e6de..e0c0794 100644 --- a/src/example/configurations/multi-projects/filter-framework/ivy.xml +++ b/src/example/configurations/multi-projects/filter-framework/ivy.xml @@ -14,23 +14,23 @@ "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. --> <ivy-module version="1.0"> <info organisation="org.apache" module="filter-framework"/> <configurations> - <conf name="api" description="only provide filter framework API"/> - <conf name="homemade-impl" extends="api" description="provide a home made implementation of our api"/> - <conf name="cc-impl" extends="api" description="provide an implementation that use apache common collection framework"/> - <conf name="test" extends="cc-impl" visibility="private" description="for testing our framework"/> + <conf name="api" description="only provide filter framework API"/> + <conf name="homemade-impl" extends="api" description="provide a home made implementation of our api"/> + <conf name="cc-impl" extends="api" description="provide an implementation that use apache common collection framework"/> + <conf name="test" extends="cc-impl" visibility="private" description="for testing our framework"/> </configurations> <publications> - <artifact name="filter-api" type="jar" conf="api" ext="jar"/> - <artifact name="filter-hmimpl" type="jar" conf="homemade-impl" ext="jar"/> - <artifact name="filter-ccimpl" type="jar" conf="cc-impl" ext="jar"/> + <artifact name="filter-api" type="jar" conf="api" ext="jar"/> + <artifact name="filter-hmimpl" type="jar" conf="homemade-impl" ext="jar"/> + <artifact name="filter-ccimpl" type="jar" conf="cc-impl" ext="jar"/> </publications> <dependencies> - <dependency org="commons-collections" name="commons-collections" rev="3.1" conf="cc-impl->default"/> + <dependency org="org.apache.commons" name="commons-collections4" rev="4.1" conf="cc-impl->default"/> <dependency org="junit" name="junit" rev="4.12" conf="test->default"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/configurations/multi-projects/filter-framework/src/filter/FilterProvider.java ---------------------------------------------------------------------- diff --git a/src/example/configurations/multi-projects/filter-framework/src/filter/FilterProvider.java b/src/example/configurations/multi-projects/filter-framework/src/filter/FilterProvider.java index a948c3e..7c9afbb 100644 --- a/src/example/configurations/multi-projects/filter-framework/src/filter/FilterProvider.java +++ b/src/example/configurations/multi-projects/filter-framework/src/filter/FilterProvider.java @@ -22,11 +22,11 @@ public final class FilterProvider { public static IFilter getFilter() { try { - Class clazz = Class.forName("filter.ccimpl.CCFilter"); + Class<?> clazz = Class.forName("filter.ccimpl.CCFilter"); return (IFilter) clazz.newInstance(); } catch (Exception e) { try { - Class clazz = Class.forName("filter.hmimpl.HMFilter"); + Class<?> clazz = Class.forName("filter.hmimpl.HMFilter"); return (IFilter) clazz.newInstance(); } catch (Exception e1) { System.err.println("No filter implementation found in classpath !"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/configurations/multi-projects/filter-framework/src/filter/ccimpl/CCFilter.java ---------------------------------------------------------------------- diff --git a/src/example/configurations/multi-projects/filter-framework/src/filter/ccimpl/CCFilter.java b/src/example/configurations/multi-projects/filter-framework/src/filter/ccimpl/CCFilter.java index 2dc71c4..af2c2fa 100644 --- a/src/example/configurations/multi-projects/filter-framework/src/filter/ccimpl/CCFilter.java +++ b/src/example/configurations/multi-projects/filter-framework/src/filter/ccimpl/CCFilter.java @@ -20,8 +20,8 @@ package filter.ccimpl; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.Predicate; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.Predicate; import filter.IFilter; public class CCFilter implements IFilter { @@ -34,10 +34,10 @@ public class CCFilter implements IFilter { return values; } - List<String> result = new ArrayList<String>(Arrays.asList(values)); - CollectionUtils.filter(result, new Predicate() { - public boolean evaluate(Object o) { - return o != null && o.toString().startsWith(prefix); + List<String> result = new ArrayList<>(Arrays.asList(values)); + CollectionUtils.filter(result, new Predicate<String>() { + public boolean evaluate(String string) { + return string != null && string.startsWith(prefix); } }); return result.toArray(new String[result.size()]); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/configurations/multi-projects/filter-framework/src/filter/hmimpl/HMFilter.java ---------------------------------------------------------------------- diff --git a/src/example/configurations/multi-projects/filter-framework/src/filter/hmimpl/HMFilter.java b/src/example/configurations/multi-projects/filter-framework/src/filter/hmimpl/HMFilter.java index 6e8b0ad..62b63f9 100644 --- a/src/example/configurations/multi-projects/filter-framework/src/filter/hmimpl/HMFilter.java +++ b/src/example/configurations/multi-projects/filter-framework/src/filter/hmimpl/HMFilter.java @@ -30,10 +30,10 @@ public class HMFilter implements IFilter { if (prefix == null) { return values; } - List<String> result = new ArrayList<String>(); - for (String string : values) { - if (string != null && string.startsWith(prefix)) { - result.add(string); + List<String> result = new ArrayList<>(); + for (String value : values) { + if (value != null && value.startsWith(prefix)) { + result.add(value); } } return result.toArray(new String[result.size()]); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/configurations/multi-projects/myapp/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/configurations/multi-projects/myapp/ivy.xml b/src/example/configurations/multi-projects/myapp/ivy.xml index 5890d33..3ad7521 100644 --- a/src/example/configurations/multi-projects/myapp/ivy.xml +++ b/src/example/configurations/multi-projects/myapp/ivy.xml @@ -14,17 +14,17 @@ "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. --> <ivy-module version="1.0"> <info organisation="org.apache" module="myapp"/> - + <configurations> - <conf name="build" visibility="private" description="compilation only need api jar" /> - <conf name="noexternaljar" description="use only company jar" /> - <conf name="withexternaljar" description="use company jar and third party jars" /> + <conf name="build" visibility="private" description="compilation only need api jar"/> + <conf name="noexternaljar" description="use only company jar"/> + <conf name="withexternaljar" description="use company jar and third party jars"/> </configurations> - + <dependencies> <dependency org="org.apache" name="filter-framework" rev="latest.integration" conf="build->api; noexternaljar->homemade-impl; withexternaljar->cc-impl"/> </dependencies> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/dependence/dependee/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/dependence/dependee/ivy.xml b/src/example/dependence/dependee/ivy.xml index c4196ff..3714320 100644 --- a/src/example/dependence/dependee/ivy.xml +++ b/src/example/dependence/dependee/ivy.xml @@ -14,11 +14,11 @@ "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. --> <ivy-module version="1.0"> <info organisation="org.apache" module="dependee"/> <dependencies> - <dependency org="commons-lang" name="commons-lang" rev="2.0"/> + <dependency org="commons-lang" name="commons-lang" rev="2.6"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/dependence/depender/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/dependence/depender/ivy.xml b/src/example/dependence/depender/ivy.xml index 1f77ce6..f4a14c5 100644 --- a/src/example/dependence/depender/ivy.xml +++ b/src/example/dependence/depender/ivy.xml @@ -14,11 +14,11 @@ "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. --> <ivy-module version="1.0"> <info organisation="org.apache" module="depender"/> <dependencies> - <dependency name="dependee" rev="latest.integration" /> + <dependency name="dependee" rev="latest.integration"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/dual/project/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/dual/project/ivy.xml b/src/example/dual/project/ivy.xml index 02d8bab..7745cd3 100644 --- a/src/example/dual/project/ivy.xml +++ b/src/example/dual/project/ivy.xml @@ -14,12 +14,12 @@ "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. --> <ivy-module version="1.0"> <info organisation="org.apache" module="hello-ivy"/> <dependencies> <dependency org="commons-httpclient" name="commons-httpclient" rev="2.0.2"/> - <dependency org="commons-lang" name="commons-lang" rev="2.0"/> + <dependency org="commons-lang" name="commons-lang" rev="2.6"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/dual/project/src/example/HelloIvy.java ---------------------------------------------------------------------- diff --git a/src/example/dual/project/src/example/HelloIvy.java b/src/example/dual/project/src/example/HelloIvy.java index 6125ff0..8ad7a9d 100644 --- a/src/example/dual/project/src/example/HelloIvy.java +++ b/src/example/dual/project/src/example/HelloIvy.java @@ -27,7 +27,7 @@ import org.apache.commons.lang.WordUtils; */ public final class HelloIvy { public static void main(String[] args) throws Exception { - String message = "hello ivy !"; + String message = "Hello Ivy!"; System.out.println("standard message : " + message); System.out.println("capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message)); @@ -42,7 +42,7 @@ public final class HelloIvy { System.out.println( "now check if httpclient dependency on commons-logging has been realized"); - Class clss = Class.forName("org.apache.commons.logging.Log"); + Class<?> clss = Class.forName("org.apache.commons.logging.Log"); System.out.println("found logging class in classpath: " + clss); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/hello-ivy/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/hello-ivy/ivy.xml b/src/example/hello-ivy/ivy.xml index da3870e..f6eeec1 100644 --- a/src/example/hello-ivy/ivy.xml +++ b/src/example/hello-ivy/ivy.xml @@ -14,12 +14,12 @@ "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. --> <ivy-module version="2.0"> <info organisation="org.apache" module="hello-ivy"/> <dependencies> - <dependency org="commons-lang" name="commons-lang" rev="2.0"/> - <dependency org="commons-cli" name="commons-cli" rev="1.0"/> + <dependency org="commons-lang" name="commons-lang" rev="2.6"/> + <dependency org="commons-cli" name="commons-cli" rev="1.4"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/hello-ivy/src/example/HelloConsole.java ---------------------------------------------------------------------- diff --git a/src/example/hello-ivy/src/example/HelloConsole.java b/src/example/hello-ivy/src/example/HelloConsole.java index c3e51d1..1d32c35 100644 --- a/src/example/hello-ivy/src/example/HelloConsole.java +++ b/src/example/hello-ivy/src/example/HelloConsole.java @@ -19,9 +19,8 @@ package example; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.lang.WordUtils; @@ -30,17 +29,18 @@ import org.apache.commons.lang.WordUtils; */ public final class HelloConsole { public static void main(String[] args) throws Exception { - Option msg = OptionBuilder.withArgName("msg") + Option msg = Option.builder("m") + .longOpt("message") .hasArg() - .withDescription("the message to capitalize") - .create("message"); + .desc("the message to capitalize") + .build(); Options options = new Options(); options.addOption(msg); - CommandLineParser parser = new GnuParser(); + CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); - String message = line.getOptionValue("message", "hello ivy !"); + String message = line.getOptionValue("m", "Hello Ivy!"); System.out.println("standard message : " + message); System.out.println("capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message)); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/console/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/console/ivy.xml b/src/example/multi-project/projects/console/ivy.xml index 959a58b..bdcb336 100644 --- a/src/example/multi-project/projects/console/ivy.xml +++ b/src/example/multi-project/projects/console/ivy.xml @@ -14,17 +14,17 @@ "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. --> <ivy-module version="1.0"> - <info + <info organisation="org.apache.ivy.example" module="console" status="integration"/> <dependencies> - <dependency name="version" rev="latest.integration" conf="default" /> - <dependency name="list" rev="latest.integration" conf="default->standalone" /> - <dependency name="find" rev="latest.integration" conf="default->standalone" /> - <dependency name="sizewhere" rev="latest.integration" conf="default->standalone" /> + <dependency name="version" rev="latest.integration" conf="default"/> + <dependency name="list" rev="latest.integration" conf="default->standalone"/> + <dependency name="find" rev="latest.integration" conf="default->standalone"/> + <dependency name="sizewhere" rev="latest.integration" conf="default->standalone"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/console/src/console/Main.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/console/src/console/Main.java b/src/example/multi-project/projects/console/src/console/Main.java index 87ab609..83dfad4 100644 --- a/src/example/multi-project/projects/console/src/console/Main.java +++ b/src/example/multi-project/projects/console/src/console/Main.java @@ -25,10 +25,10 @@ import java.lang.reflect.Method; public final class Main { - private static final Collection QUIT_COMMANDS = - Arrays.asList(new String[] {"quit", "q", "exit"}); - private static final Collection HELP_COMMANDS = - Arrays.asList(new String[] {"help", "h", "?"}); + private static final Collection<String> QUIT_COMMANDS = + Arrays.asList("quit", "q", "exit"); + private static final Collection<String> HELP_COMMANDS = + Arrays.asList("help", "h", "?"); public static void main(String[] a) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); @@ -51,7 +51,7 @@ public final class Main { try { String[] args = new String[split.length - 1]; System.arraycopy(split, 1, args, 0, args.length); - Class cl = Class.forName(split[0] + ".Main"); + Class<?> cl = Class.forName(split[0] + ".Main"); Method m = cl.getMethod("main", new Class[] {String[].class}); m.invoke(null, new Object[] {args}); } catch (Exception ex) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/find/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/find/ivy.xml b/src/example/multi-project/projects/find/ivy.xml index ce19513..9fc92ee 100644 --- a/src/example/multi-project/projects/find/ivy.xml +++ b/src/example/multi-project/projects/find/ivy.xml @@ -14,10 +14,10 @@ "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. --> <ivy-module version="1.0"> - <info + <info organisation="org.apache.ivy.example" module="find" status="integration"/> @@ -26,12 +26,12 @@ <conf name="standalone" extends="core"/> </configurations> <publications> - <artifact name="find" type="jar" conf="core" /> + <artifact name="find" type="jar" conf="core"/> </publications> <dependencies> - <dependency name="version" rev="latest.integration" conf="core->default" /> - <dependency name="list" rev="latest.integration" conf="core" /> - <dependency org="commons-collections" name="commons-collections" rev="3.1" conf="core->default" /> - <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" /> + <dependency name="version" rev="latest.integration" conf="core->default"/> + <dependency name="list" rev="latest.integration" conf="core"/> + <dependency org="org.apache.commons" name="commons-collections4" rev="4.1" conf="core->default"/> + <dependency org="commons-cli" name="commons-cli" rev="1.4" conf="standalone->default"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/find/src/find/FindFile.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/find/src/find/FindFile.java b/src/example/multi-project/projects/find/src/find/FindFile.java index 8e54dc2..7df6379 100644 --- a/src/example/multi-project/projects/find/src/find/FindFile.java +++ b/src/example/multi-project/projects/find/src/find/FindFile.java @@ -17,28 +17,28 @@ */ package find; -import version.Version; -import list.ListFile; - import java.util.Collection; import java.io.File; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.Predicate; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.Predicate; + +import static list.ListFile.list; +import static version.Version.register; public final class FindFile { static { - Version.register("find"); + register("find"); } - public static Collection find(File dir, String name) { - return find(ListFile.list(dir), name); + public static Collection<File> find(File dir, String name) { + return find(list(dir), name); } - private static Collection find(Collection files, final String name) { - return CollectionUtils.select(files, new Predicate() { - public boolean evaluate(Object o) { - return ((File) o).getName().contains(name); + private static Collection<File> find(Collection<File> files, final String name) { + return CollectionUtils.select(files, new Predicate<File>() { + public boolean evaluate(File file) { + return file.getName().contains(name); } }); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/find/src/find/Main.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/find/src/find/Main.java b/src/example/multi-project/projects/find/src/find/Main.java index ccfa1ce..731f168 100644 --- a/src/example/multi-project/projects/find/src/find/Main.java +++ b/src/example/multi-project/projects/find/src/find/Main.java @@ -17,29 +17,29 @@ */ package find; -import java.io.File; -import java.util.Collection; -import java.util.Iterator; - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import java.io.File; +import java.util.Collection; + public final class Main { private static Options getOptions() { - Option dir = OptionBuilder.withArgName("dir") + Option dir = Option.builder("d") + .longOpt("dir") .hasArg() - .withDescription("list files in given dir") - .create("dir"); - Option name = OptionBuilder.withArgName("name") + .desc("list files in given dir") + .build(); + Option name = Option.builder("n") + .longOpt("name") .hasArg() - .withDescription("list files with given name") - .create("name"); + .desc("list files with given name") + .build(); Options options = new Options(); options.addOption(dir); @@ -52,14 +52,14 @@ public final class Main { Options options = getOptions(); try { - CommandLineParser parser = new GnuParser(); + CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); - File dir = new File(line.getOptionValue("dir", ".")); - String name = line.getOptionValue("name", "jar"); - Collection files = FindFile.find(dir, name); + File dir = new File(line.getOptionValue("d", ".")); + String name = line.getOptionValue("n", "jar"); + Collection<File> files = FindFile.find(dir, name); System.out.println("listing files in " + dir + " containing " + name); - for (Object file : files) { + for (File file : files) { System.out.println("\t" + file + "\n"); } } catch (ParseException exp) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/list/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/list/ivy.xml b/src/example/multi-project/projects/list/ivy.xml index 8251fdc..ebb6d06 100644 --- a/src/example/multi-project/projects/list/ivy.xml +++ b/src/example/multi-project/projects/list/ivy.xml @@ -14,10 +14,10 @@ "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. --> <ivy-module version="1.0"> - <info + <info organisation="org.apache.ivy.example" module="list" status="integration"/> @@ -26,10 +26,10 @@ <conf name="standalone" extends="core"/> </configurations> <publications> - <artifact name="list" type="jar" conf="core" /> + <artifact name="list" type="jar" conf="core"/> </publications> <dependencies> - <dependency name="version" rev="latest.integration" conf="core->default" /> - <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" /> + <dependency name="version" rev="latest.integration" conf="core->default"/> + <dependency org="commons-cli" name="commons-cli" rev="1.4" conf="standalone->default"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/list/src/list/ListFile.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/list/src/list/ListFile.java b/src/example/multi-project/projects/list/src/list/ListFile.java index 14a28e7..3025389 100644 --- a/src/example/multi-project/projects/list/src/list/ListFile.java +++ b/src/example/multi-project/projects/list/src/list/ListFile.java @@ -17,23 +17,24 @@ */ package list; -import version.Version; import java.util.Collection; import java.util.ArrayList; import java.io.File; +import static version.Version.register; + public final class ListFile { static { - Version.register("list"); + register("list"); } - public static Collection list(File dir) { - Collection files = new ArrayList(); + public static Collection<File> list(File dir) { + Collection<File> files = new ArrayList<File>(); return list(dir, files); } - private static Collection list(File file, Collection files) { + private static Collection<File> list(File file, Collection<File> files) { if (file.isDirectory()) { for (File f : file.listFiles()) { list(f, files); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/list/src/list/Main.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/list/src/list/Main.java b/src/example/multi-project/projects/list/src/list/Main.java index c9915b6..c45f0d9 100644 --- a/src/example/multi-project/projects/list/src/list/Main.java +++ b/src/example/multi-project/projects/list/src/list/Main.java @@ -18,24 +18,22 @@ package list; import java.io.File; -import java.util.Collection; -import java.util.Iterator; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; public final class Main { private static Options getOptions() { - Option dir = OptionBuilder.withArgName("dir") + Option dir = Option.builder("d") + .longOpt("dir") .hasArg() - .withDescription("list files in given dir") - .create("dir"); + .desc("list files in given dir") + .build(); Options options = new Options(); options.addOption(dir); @@ -47,12 +45,12 @@ public final class Main { Options options = getOptions(); try { - CommandLineParser parser = new GnuParser(); + CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); - File dir = new File(line.getOptionValue("dir", ".")); + File dir = new File(line.getOptionValue("d", ".")); System.out.println("listing files in " + dir); - for (Object file : ListFile.list(dir)) { + for (File file : ListFile.list(dir)) { System.out.println("\t" + file + "\n"); } } catch (ParseException exp) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/size/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/size/ivy.xml b/src/example/multi-project/projects/size/ivy.xml index ff20d0e..b7c8591 100644 --- a/src/example/multi-project/projects/size/ivy.xml +++ b/src/example/multi-project/projects/size/ivy.xml @@ -14,15 +14,15 @@ "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. --> <ivy-module version="1.0"> - <info + <info organisation="org.apache.ivy.example" module="size" status="integration"/> <dependencies> - <dependency name="version" rev="latest.integration" conf="default" /> - <dependency name="list" rev="latest.integration" conf="default->core" /> + <dependency name="version" rev="latest.integration" conf="default"/> + <dependency name="list" rev="latest.integration" conf="default->core"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/size/src/size/FileSize.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/size/src/size/FileSize.java b/src/example/multi-project/projects/size/src/size/FileSize.java index c2efcf1..a6e752d 100644 --- a/src/example/multi-project/projects/size/src/size/FileSize.java +++ b/src/example/multi-project/projects/size/src/size/FileSize.java @@ -17,24 +17,26 @@ */ package size; -import version.Version; -import java.util.Collection; -import java.util.Iterator; import java.io.File; +import java.util.Collection; + +import static list.ListFile.list; +import static version.Version.register; public final class FileSize { static { - Version.register("size"); + register("size"); } + @SuppressWarnings("unused") public static long totalSize(File dir) { - return totalSize(list.ListFile.list(dir)); + return totalSize(list(dir)); } - public static long totalSize(Collection files) { + public static long totalSize(Collection<File> files) { long total = 0; - for (Object file : files) { - total += ((File) file).length(); + for (File file : files) { + total += file.length(); } return total; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/sizewhere/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/sizewhere/ivy.xml b/src/example/multi-project/projects/sizewhere/ivy.xml index 344cb3f..787520d 100644 --- a/src/example/multi-project/projects/sizewhere/ivy.xml +++ b/src/example/multi-project/projects/sizewhere/ivy.xml @@ -14,10 +14,10 @@ "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. --> <ivy-module version="1.0"> - <info + <info organisation="org.apache.ivy.example" module="sizewhere" status="integration"/> @@ -26,12 +26,12 @@ <conf name="standalone" extends="core"/> </configurations> <publications> - <artifact name="sizewhere" type="jar" conf="core" /> + <artifact name="sizewhere" type="jar" conf="core"/> </publications> <dependencies> - <dependency name="version" rev="latest.integration" conf="core->default" /> - <dependency name="size" rev="latest.integration" conf="core->default" /> - <dependency name="find" rev="latest.integration" conf="core" /> - <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" /> + <dependency name="version" rev="latest.integration" conf="core->default"/> + <dependency name="size" rev="latest.integration" conf="core->default"/> + <dependency name="find" rev="latest.integration" conf="core"/> + <dependency org="commons-cli" name="commons-cli" rev="1.4" conf="standalone->default"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/sizewhere/src/sizewhere/Main.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/sizewhere/src/sizewhere/Main.java b/src/example/multi-project/projects/sizewhere/src/sizewhere/Main.java index dc2a996..a2509e3 100644 --- a/src/example/multi-project/projects/sizewhere/src/sizewhere/Main.java +++ b/src/example/multi-project/projects/sizewhere/src/sizewhere/Main.java @@ -17,27 +17,28 @@ */ package sizewhere; -import java.io.File; - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import java.io.File; + public final class Main { private static Options getOptions() { - Option dir = OptionBuilder.withArgName("dir") + Option dir = Option.builder("d") + .longOpt("dir") .hasArg() - .withDescription("give total size of files in given dir") - .create("dir"); - Option name = OptionBuilder.withArgName("name") + .desc("give total size of files in given dir") + .build(); + Option name = Option.builder("n") + .longOpt("name") .hasArg() - .withDescription("give total size of files with given name") - .create("name"); + .desc("give total size of files with given name") + .build(); Options options = new Options(); options.addOption(dir); @@ -49,17 +50,16 @@ public final class Main { public static void main(String[] args) throws Exception { Options options = getOptions(); try { - - CommandLineParser parser = new GnuParser(); + CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); - File dir = new File(line.getOptionValue("dir", ".")); - String name = line.getOptionValue("name", "jar"); + File dir = new File(line.getOptionValue("d", ".")); + String name = line.getOptionValue("n", "jar"); System.out.println("total size of files in " + dir + " containing " + name + ": " + SizeWhere.totalSize(dir, name)); } catch (ParseException exp) { - // oops, something went wrong - System.err.println("Parsing failed. Reason: " + exp.getMessage()); + // oops, something went wrong + System.err.println("Parsing failed. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("sizewhere", options); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java b/src/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java index df27f31..0b5cc62 100644 --- a/src/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java +++ b/src/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java @@ -17,19 +17,20 @@ */ package sizewhere; -import version.Version; import size.FileSize; -import find.FindFile; import java.io.File; +import static find.FindFile.find; +import static version.Version.register; + public final class SizeWhere { static { - Version.register("sizewhere"); + register("sizewhere"); } public static long totalSize(File dir, String name) { - return FileSize.totalSize(FindFile.find(dir, name)); + return FileSize.totalSize(find(dir, name)); } private SizeWhere() { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/version/ivy.xml ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/version/ivy.xml b/src/example/multi-project/projects/version/ivy.xml index 7a29b46..e3e2b14 100644 --- a/src/example/multi-project/projects/version/ivy.xml +++ b/src/example/multi-project/projects/version/ivy.xml @@ -14,10 +14,10 @@ "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. --> <ivy-module version="1.0"> - <info + <info organisation="org.apache.ivy.example" module="version" status="integration"/> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/src/example/multi-project/projects/version/src/version/Version.java ---------------------------------------------------------------------- diff --git a/src/example/multi-project/projects/version/src/version/Version.java b/src/example/multi-project/projects/version/src/version/Version.java index 9c9a605..9c34c32 100644 --- a/src/example/multi-project/projects/version/src/version/Version.java +++ b/src/example/multi-project/projects/version/src/version/Version.java @@ -24,11 +24,11 @@ import java.util.HashMap; public final class Version { static { - versions = new HashMap(); + versions = new HashMap<>(); register("version"); } - private static Map versions; + private static Map<String, String> versions; public static void register(String module) { try { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/test/java/org/apache/ivy/ant/AntCallTriggerTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/AntCallTriggerTest.java b/test/java/org/apache/ivy/ant/AntCallTriggerTest.java index d1f79c7..f92a714 100644 --- a/test/java/org/apache/ivy/ant/AntCallTriggerTest.java +++ b/test/java/org/apache/ivy/ant/AntCallTriggerTest.java @@ -149,12 +149,9 @@ public class AntCallTriggerTest { System.setErr(err); System.setIn(in); } - } catch (RuntimeException exc) { + } catch (RuntimeException | Error exc) { error = exc; throw exc; - } catch (Error err) { - error = err; - throw err; } finally { project.fireBuildFinished(error); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java b/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java index 7451bd3..95eb9a9 100644 --- a/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java +++ b/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java @@ -63,11 +63,8 @@ public class BuildOBRTaskTest { private BundleRepoDescriptor readObr(File obrFile) throws IOException, SAXException { BundleRepoDescriptor obr; - FileInputStream in = new FileInputStream(obrFile); - try { + try (FileInputStream in = new FileInputStream(obrFile)) { obr = OBRXMLParser.parse(obrFile.toURI(), in); - } finally { - in.close(); } return obr; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/test/java/org/apache/ivy/ant/FixDepsTaskTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/FixDepsTaskTest.java b/test/java/org/apache/ivy/ant/FixDepsTaskTest.java index 8811348..0223fed 100644 --- a/test/java/org/apache/ivy/ant/FixDepsTaskTest.java +++ b/test/java/org/apache/ivy/ant/FixDepsTaskTest.java @@ -217,7 +217,7 @@ public class FixDepsTaskTest { } private List<String> toString(List<DependencyDescriptor> list) { - List<String> strings = new ArrayList<String>(list.size()); + List<String> strings = new ArrayList<>(list.size()); for (DependencyDescriptor dd : list) { strings.add(dd.toString()); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/test/java/org/apache/ivy/ant/IvyDeliverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyDeliverTest.java b/test/java/org/apache/ivy/ant/IvyDeliverTest.java index 881b971..0e94d4d 100644 --- a/test/java/org/apache/ivy/ant/IvyDeliverTest.java +++ b/test/java/org/apache/ivy/ant/IvyDeliverTest.java @@ -133,28 +133,23 @@ public class IvyDeliverTest { // we could do a better job of this with xmlunit int lineNo = 1; - BufferedReader merged = new BufferedReader(new FileReader(delivered)); - BufferedReader expected = new BufferedReader(new InputStreamReader(getClass() - .getResourceAsStream("ivy-extends-merged.xml"))); - try { - for (String mergeLine = merged.readLine(), expectedLine = expected.readLine(); mergeLine != null - && expectedLine != null; mergeLine = merged.readLine(), expectedLine = expected - .readLine()) { - - mergeLine = mergeLine.trim(); - expectedLine = expectedLine.trim(); - - if (!mergeLine.startsWith("<info")) { - assertEquals("published descriptor matches at line[" + lineNo + "]", - expectedLine.trim(), mergeLine.trim()); - } - - ++lineNo; - } - } finally { - merged.close(); - expected.close(); - } + try (BufferedReader merged = new BufferedReader(new FileReader(delivered)); + BufferedReader expected = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("ivy-extends-merged.xml")))) { + for (String mergeLine = merged.readLine(), expectedLine = expected.readLine(); + mergeLine != null && expectedLine != null; + mergeLine = merged.readLine(), expectedLine = expected.readLine()) { + + mergeLine = mergeLine.trim(); + expectedLine = expectedLine.trim(); + + if (!mergeLine.startsWith("<info")) { + assertEquals("published descriptor matches at line[" + lineNo + "]", + expectedLine.trim(), mergeLine.trim()); + } + + ++lineNo; + } + } } @Test @@ -385,7 +380,7 @@ public class IvyDeliverTest { md.getModuleRevisionId()); DependencyDescriptor[] dds = md.getDependencies(); assertEquals(1, dds.length); - Map<String, String> extraAtt = new HashMap<String, String>(); + Map<String, String> extraAtt = new HashMap<>(); extraAtt.put("myExtraAtt", "myValue"); assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2", extraAtt), dds[0].getDependencyRevisionId()); @@ -423,8 +418,8 @@ public class IvyDeliverTest { File list = new File("build/test/retrieve"); String[] files = list.list(); - HashSet<String> actualFileSet = new HashSet<String>(Arrays.asList(files)); - HashSet<String> expectedFileSet = new HashSet<String>(); + HashSet<String> actualFileSet = new HashSet<>(Arrays.asList(files)); + HashSet<String> expectedFileSet = new HashSet<>(); for (DependencyDescriptor dd : dds) { String name = dd.getDependencyId().getName(); String rev = dd.getDependencyRevisionId().getRevision(); @@ -470,8 +465,8 @@ public class IvyDeliverTest { File list = new File("build/test/retrieve"); String[] files = list.list(); - HashSet<String> actualFileSet = new HashSet<String>(Arrays.asList(files)); - HashSet<String> expectedFileSet = new HashSet<String>(); + HashSet<String> actualFileSet = new HashSet<>(Arrays.asList(files)); + HashSet<String> expectedFileSet = new HashSet<>(); for (DependencyDescriptor dd : dds) { String name = dd.getDependencyId().getName(); String rev = dd.getDependencyRevisionId().getRevision(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/fb3ccf60/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java b/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java index 6adc823..a1de1db 100644 --- a/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java +++ b/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java @@ -70,6 +70,7 @@ public class ModuleIdTest { ModuleId moduleId2 = new ModuleId(null, name); assertNotNull(moduleId); + assertFalse(moduleId.equals(null)); assertFalse(moduleId.equals(moduleId2)); assertFalse(moduleId2.equals(moduleId)); }