Repository: ant-ivy Updated Branches: refs/heads/master 198af5cdf -> 73f7cf413
Added makepom option to main/standalone This close PR #71 at github.com/apache/ant-ivy Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/73f7cf41 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/73f7cf41 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/73f7cf41 Branch: refs/heads/master Commit: 73f7cf413d07925db3f6a5abc4fb1a5543dce52c Parents: 198af5c Author: Thomas Pasch <thomas.pa...@gmx.de> Authored: Tue Mar 27 21:17:01 2018 +0200 Committer: Jaikiran Pai <jaiki...@apache.org> Committed: Wed Apr 4 21:25:55 2018 +0530 ---------------------------------------------------------------------- .gitignore | 1 + asciidoc/release-notes.adoc | 1 + src/java/org/apache/ivy/Main.java | 13 +++++++++++++ test/java/org/apache/ivy/MainTest.java | 26 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/73f7cf41/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 4f95270..8eb2a90 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ test/repositories/norevision/ivy-mod1.1.xml test/repositories/norevision/mod1.1.jar test/test-repo/bundlerepo/*.jar test/test-repo/ivyrepo/org.apache.ivy.osgi +out/ http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/73f7cf41/asciidoc/release-notes.adoc ---------------------------------------------------------------------- diff --git a/asciidoc/release-notes.adoc b/asciidoc/release-notes.adoc index 3efa671..f2479ef 100644 --- a/asciidoc/release-notes.adoc +++ b/asciidoc/release-notes.adoc @@ -93,6 +93,7 @@ For details about the following changes, check our JIRA install at link:https:// - 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 (jira:IVY-1529[]) - NEW: Add (conditional) support for SHA-256, SHA-512 and SHA-384 checksum algorithms (jira:IVY-1554[]) (Thanks to Jaikiran Pai) +- NEW: The standalone Ivy jar can now be used to generate a pom file for the resolved module, using the `makepom` option (Thanks to link:https://github.com/aanno[aanno]) //// http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/73f7cf41/src/java/org/apache/ivy/Main.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/Main.java b/src/java/org/apache/ivy/Main.java index e959bd5..6be36cd 100644 --- a/src/java/org/apache/ivy/Main.java +++ b/src/java/org/apache/ivy/Main.java @@ -47,6 +47,8 @@ import org.apache.ivy.core.resolve.ResolveOptions; import org.apache.ivy.core.resolve.ResolveProcessException; import org.apache.ivy.core.retrieve.RetrieveOptions; import org.apache.ivy.core.settings.IvySettings; +import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter; +import org.apache.ivy.plugins.parser.m2.PomWriterOptions; import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter; import org.apache.ivy.plugins.report.XmlReportParser; import org.apache.ivy.util.DefaultMessageLogger; @@ -174,6 +176,10 @@ public final class Main { new OptionBuilder("overwrite").description( "overwrite files in the repository if they exist").create()) + .addCategory("makepom options") + .addOption(new OptionBuilder("makepom").arg("pomfilepath") + .description("Creates a pom file for the module").create()) + .addCategory("http auth options") .addOption( new OptionBuilder("realm").arg("realm") @@ -199,6 +205,7 @@ public final class Main { new OptionBuilder("cp").arg("cp") .description("extra classpath to use when launching process").create()) + .addCategory("message options") .addOption( new OptionBuilder("debug").description("set message level to debug").create()) @@ -419,6 +426,12 @@ public final class Main { .setOverwrite(line.hasOption("overwrite"))); } } + if (line.hasOption("makepom")) { + final String pomFilePath = line.getOptionValue("makepom", "pom.xml"); + final File pomFile = new File(pomFilePath); + PomModuleDescriptorWriter.write(md, pomFile, new PomWriterOptions()); + Message.debug("Generated a pom file for module at " + pomFile); + } if (line.hasOption("main")) { // check if the option cp has been set List<File> fileList = getExtraClasspathFileList(line); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/73f7cf41/test/java/org/apache/ivy/MainTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/MainTest.java b/test/java/org/apache/ivy/MainTest.java index 063f600..60e3d0b 100644 --- a/test/java/org/apache/ivy/MainTest.java +++ b/test/java/org/apache/ivy/MainTest.java @@ -18,6 +18,8 @@ package org.apache.ivy; import org.apache.ivy.core.retrieve.RetrieveOptions; +import org.apache.ivy.core.settings.IvySettings; +import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser; import org.apache.ivy.util.CacheCleaner; import org.apache.ivy.util.cli.CommandLine; import org.apache.ivy.util.cli.ParseException; @@ -26,6 +28,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; import java.io.File; import java.nio.file.Files; @@ -36,6 +39,7 @@ import java.util.HashSet; import java.util.Set; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -46,6 +50,9 @@ public class MainTest { @Rule public ExpectedException expExc = ExpectedException.none(); + @Rule + public TemporaryFolder tempDir = new TemporaryFolder(); + @Before public void setUp() { cache = new File("build/cache"); @@ -182,6 +189,25 @@ public class MainTest { assertTrue("Content at " + retrieveArtifactPath + " was not overwritten by retrieve task", Files.readAllBytes(retrieveArtifactPath).length > 0); } + /** + * Tests that the {@code makepom} option works as expected + * + * @throws Exception if something goes wrong + */ + @Test + public void testMakePom() throws Exception { + final String pomFilePath = this.tempDir.getRoot().getAbsolutePath() + File.separator + "testmakepom.xml"; + final String[] args = new String[]{"-settings", "test/repositories/ivysettings.xml", "-makepom", pomFilePath, + "-ivy", "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"}; + final CommandLine parsedCommand = Main.getParser().parse(args); + final String parsedMakePomPath = parsedCommand.getOptionValue("makepom"); + assertEquals("Unexpected makepom parsed", pomFilePath, parsedMakePomPath); + assertFalse("pom file " + pomFilePath + " already exists", new File(pomFilePath).exists()); + // run the command + run(args); + assertTrue("pom file hasn't been generated at " + pomFilePath, new File(pomFilePath).isFile()); + } + private void run(String[] args) throws Exception { Main.run(Main.getParser(), args); }