Fix YangToSourcesPluginTestIT failure 05/41505/3
authorMichael Vorburger <vorburger@redhat.com>
Thu, 7 Jul 2016 16:27:45 +0000 (18:27 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 18 Jul 2016 08:51:46 +0000 (08:51 +0000)
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 <vorburger@redhat.com>
yang/yang-maven-plugin-it/pom.xml
yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java

index ec49020712e0bb50c452f029b29e2c8706913684..22660113aed2cf96d5670be2ba2f94aa3a55271c 100644 (file)
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <artifactId>maven-help-plugin</artifactId>
+                <configuration>
+                    <output>${project.build.directory}/effective-settings.xml</output>
+                </configuration>
+                <executions>
+                    <execution>
+                      <phase>pre-integration-test</phase>
+                      <goals>
+                          <goal>effective-settings</goal>
+                      </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
index 7b1e11e4660e73348ee1610774e53c79983f812c..9df96367a296192302b70fb813f8c53c5129cceb 100644 (file)
@@ -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<String> 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();
+        }
+    }
+
 }