From 848f1fdc2418847e1237a12c9b19e30de373d029 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Thu, 7 Jul 2016 18:27:45 +0200 Subject: [PATCH] Fix YangToSourcesPluginTestIT failure Inspired by http://blog2.vorburger.ch/2016/05/how-to-make-maven-archetype-plugin.html The YangToSourcesPluginTestIT obviously does pass on Jenkins, but that relies on magical environment variables. I'm sure it also works locally for those who use the custom ODL settings.xml globally - but I don't; I just use "mvn -s odl.xml" kind of thing. This fix makes the YangToSourcesPluginTestIT pass even then, because it will now re-use the real "effective" settings XML under which Maven was started. Change-Id: I1edbed691ac1a01c8bfc1c8178d4836781aba0a1 Signed-off-by: Michael Vorburger --- yang/yang-maven-plugin-it/pom.xml | 14 ++++++++++++++ .../plugin/it/YangToSourcesPluginTestIT.java | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/yang/yang-maven-plugin-it/pom.xml b/yang/yang-maven-plugin-it/pom.xml index ec49020712..22660113ae 100644 --- a/yang/yang-maven-plugin-it/pom.xml +++ b/yang/yang-maven-plugin-it/pom.xml @@ -91,6 +91,20 @@ + + maven-help-plugin + + ${project.build.directory}/effective-settings.xml + + + + pre-integration-test + + effective-settings + + + + diff --git a/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java b/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java index 7b1e11e466..9df96367a2 100644 --- a/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java +++ b/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java @@ -19,6 +19,7 @@ import java.io.InputStream; import java.net.URISyntaxException; import java.net.URL; import java.util.Arrays; +import java.util.Optional; import java.util.Properties; import org.apache.maven.it.VerificationException; import org.apache.maven.it.Verifier; @@ -134,6 +135,9 @@ public class YangToSourcesPluginTestIT { if (GLOBAL_SETTINGS_OVERRIDE != null) { verifier.addCliOption("-gs"); verifier.addCliOption(GLOBAL_SETTINGS_OVERRIDE); + } else if (getEffectiveSettingsXML().isPresent()) { + verifier.addCliOption("-gs"); + verifier.addCliOption(getEffectiveSettingsXML().get()); } if (USER_SETTINGS_OVERRIDE != null) { verifier.addCliOption("-s"); @@ -182,4 +186,16 @@ public class YangToSourcesPluginTestIT { return sp.getProperty("target.dir"); } + private static Optional getEffectiveSettingsXML() throws URISyntaxException, VerificationException, IOException { + final URL path = YangToSourcesPluginTestIT.class.getResource("/test-parent/pom.xml"); + File buildDir = new File(path.toURI()).getParentFile().getParentFile().getParentFile(); + File effectiveSettingsXML = new File(buildDir, "effective-settings.xml"); + if (effectiveSettingsXML.exists()) { + return Optional.of(effectiveSettingsXML.getAbsolutePath()); + } else { + fail(effectiveSettingsXML.getAbsolutePath()); + return Optional.empty(); + } + } + } -- 2.36.6