NO-JIRA Improving dependency-scan for compatibility-tests
This commit is contained in:
parent
b93613142f
commit
71b781d919
|
@ -150,7 +150,7 @@ public abstract class ArtemisAbstractPlugin extends AbstractMojo {
|
|||
}
|
||||
});
|
||||
}
|
||||
getLog().info(writer.toString());
|
||||
getLog().debug(writer.toString());
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.maven;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
|
@ -56,6 +59,9 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin {
|
|||
@Parameter
|
||||
private String variableName;
|
||||
|
||||
@Parameter
|
||||
private String file;
|
||||
|
||||
@Parameter
|
||||
private String pathSeparator = File.pathSeparator;
|
||||
|
||||
|
@ -85,23 +91,23 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin {
|
|||
remoteRepos.add(repo);
|
||||
}
|
||||
}
|
||||
getLog().info("Local " + localRepository);
|
||||
getLog().debug("Local " + localRepository);
|
||||
project = (MavenProject) getPluginContext().get("project");
|
||||
|
||||
Map properties = getPluginContext();
|
||||
|
||||
Set<Map.Entry> entries = properties.entrySet();
|
||||
|
||||
getLog().info("Entries.size " + entries.size());
|
||||
getLog().debug("Entries.size " + entries.size());
|
||||
for (Map.Entry entry : entries) {
|
||||
getLog().info("... key=" + entry.getKey() + " = " + entry.getValue());
|
||||
getLog().debug("... key=" + entry.getKey() + " = " + entry.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Set<File> filesSet = resolveDependencies(libListWithDeps, libList);
|
||||
|
||||
if (variableName != null) {
|
||||
if (variableName != null || file != null) {
|
||||
String separatorUsed = "";
|
||||
for (File f : filesSet) {
|
||||
buffer.append(separatorUsed);
|
||||
|
@ -111,6 +117,22 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin {
|
|||
|
||||
String classPathGenerated = buffer.toString();
|
||||
setVariable(classPathGenerated);
|
||||
|
||||
if (file != null) {
|
||||
File fileOutput = new File(file);
|
||||
try {
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("Generating file " + file + " with classpath output for " + variableName);
|
||||
getLog().debug(classPathGenerated);
|
||||
}
|
||||
PrintStream printStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(fileOutput)));
|
||||
printStream.print(classPathGenerated);
|
||||
printStream.close();
|
||||
} catch (Exception e) {
|
||||
getLog().error("could not generate file with classpath", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (targetFolder != null) {
|
||||
|
@ -138,7 +160,7 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin {
|
|||
private void setVariable(String classPathGenerated) {
|
||||
if (variableName != null) {
|
||||
project.getProperties().setProperty(variableName, classPathGenerated);
|
||||
getLog().info("dependency-scan setting: -D" + variableName + "=\"" + classPathGenerated + "\"");
|
||||
getLog().debug("dependency-scan setting: -D" + variableName + "=\"" + classPathGenerated + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -286,6 +286,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>artemis-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<!-- The executions of dependency-scan will calculate dependencies for each specific version used here on this testsuite. -->
|
||||
<execution>
|
||||
|
@ -307,7 +308,7 @@
|
|||
<libList>
|
||||
<arg>org.apache.activemq.tests:compatibility-tests:${project.version}</arg>
|
||||
</libList>
|
||||
<variableName>ARTEMIS-SNAPSHOT</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-SNAPSHOT.cp</file>
|
||||
</configuration>
|
||||
</execution><!-- The executions of dependency-scan will calculate dependencies for each specific version used here on this testsuite. -->
|
||||
<execution>
|
||||
|
@ -335,7 +336,7 @@
|
|||
<arg>org.apache.activemq:artemis-jakarta-service-extensions:${project.version}</arg>
|
||||
<arg>org.apache.activemq.tests:compatibility-tests:${project.version}</arg>
|
||||
</libList>
|
||||
<variableName>ARTEMIS-JAKARTAEE</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-JAKARTAEE.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -359,7 +360,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-263</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-263.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -383,7 +384,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-270</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-270.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -409,7 +410,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-2_10_0</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-2_10_0.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -435,7 +436,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-2_17_0</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-2_17_0.cp</file>
|
||||
</configuration>
|
||||
</execution> <execution>
|
||||
<phase>compile</phase>
|
||||
|
@ -460,7 +461,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-2_18_0</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-2_18_0.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
|
@ -487,7 +488,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-2_22_0</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-2_22_0.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -512,7 +513,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-240</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-240.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -537,7 +538,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-210</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-210.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -562,7 +563,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-200</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-200.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -586,7 +587,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-140</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-140.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -611,7 +612,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>ARTEMIS-155</variableName>
|
||||
<file>${basedir}/target/ARTEMIS-155.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -636,7 +637,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>HORNETQ-235</variableName>
|
||||
<file>${basedir}/target/HORNETQ-235.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
@ -661,7 +662,7 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>HORNETQ-247</variableName>
|
||||
<file>${basedir}/target/HORNETQ-247.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
|
@ -682,110 +683,11 @@
|
|||
</libList>
|
||||
<!-- for future maintainers, notice that if you add new variables you also need to add the system property
|
||||
otherwise this is not captured, search for the word @@@@ on this pom where I left anothr comment -->
|
||||
<variableName>AMQ_5_11</variableName>
|
||||
<file>${basedir}/target/AMQ_5_11.cp</file>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- @@@@ as I stated above, you also need to define the system property here otherwise the property won't be captured
|
||||
by the execution.
|
||||
I couldn't find a better way to define this inside the maven plugin, perhaps there's an easier way,
|
||||
if you know a way to get rid of this it would be a nice improvement -->
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>ARTEMIS-SNAPSHOT</name>
|
||||
<value>${ARTEMIS-SNAPSHOT}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-200</name>
|
||||
<value>${ARTEMIS-200}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-210</name> <!-- 2.1.0 -->
|
||||
<value>${ARTEMIS-210}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-2_10_0</name> <!-- 2.10.0 -->
|
||||
<value>${ARTEMIS-2_10_0}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-2_17_0</name>
|
||||
<value>${ARTEMIS-2_17_0}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-2_18_0</name>
|
||||
<value>${ARTEMIS-2_18_0}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-2_22_0</name>
|
||||
<value>${ARTEMIS-2_22_0}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-240</name>
|
||||
<value>${ARTEMIS-240}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-155</name>
|
||||
<value>${ARTEMIS-155}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-140</name>
|
||||
<value>${ARTEMIS-140}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>HORNETQ-235</name>
|
||||
<value>${HORNETQ-235}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>HORNETQ-247</name>
|
||||
<value>${HORNETQ-247}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-263</name>
|
||||
<value>${ARTEMIS-263}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-270</name>
|
||||
<value>${ARTEMIS-270}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>ARTEMIS-JAKARTAEE</name>
|
||||
<value>${ARTEMIS-JAKARTAEE}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>AMQ_5_11</name>
|
||||
<value>${AMQ_5_11}</value>
|
||||
</property>
|
||||
<variableName>AMQ_5_11</variableName>
|
||||
</systemProperties>
|
||||
<skipTests>${skipCompatibilityTests}</skipTests>
|
||||
<argLine>${modular.jdk.surefire.arg} -Djgroups.bind_addr=::1 ${activemq-surefire-argline}</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- during testing and debugging, it may be useful to add all the classpath variables to your IDE settings and run compatibility tests manually.
|
||||
uncomment this next group so you will have a big line to add to your test setting -->
|
||||
<!-- <plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo>You can use this line to include into your tests runnings</echo>
|
||||
<echo>-DARTEMIS-200="${ARTEMIS-200}" -DARTEMIS-210="${ARTEMIS-210}" -DARTEMIS-263="${ARTEMIS-263}" -DARTEMIS-240="${ARTEMIS-240}" -DARTEMIS-155="${ARTEMIS-155}" -DARTEMIS-140="${ARTEMIS-140}" -DHORNETQ-235="${HORNETQ-235}" -DHORNETQ-247="${HORNETQ-247}" -DARTEMIS-270="${ARTEMIS-270}" -DARTEMIS-240="${ARTEMIS-240}" -DARTEMIS-155="${ARTEMIS-155}" -DARTEMIS-140="${ARTEMIS-140}"</echo>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin> -->
|
||||
<plugin>
|
||||
<groupId>org.apache.servicemix.tooling</groupId>
|
||||
<artifactId>depends-maven-plugin</artifactId>
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.activemq.artemis.tests.compatibility.base;
|
|||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
@ -27,6 +28,7 @@ import java.util.Map;
|
|||
import org.apache.activemq.artemis.tests.compatibility.GroovyRun;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
|
@ -166,23 +168,17 @@ public class ClasspathBase {
|
|||
}
|
||||
}
|
||||
|
||||
String value = System.getProperty(name);
|
||||
|
||||
if (!printed.contains(name)) {
|
||||
boolean ok = value != null && !value.trim().isEmpty();
|
||||
if (!ok) {
|
||||
System.out.println("Add \"-D" + name + "=\'CLASSPATH\'\" into your VM settings");
|
||||
System.out.println("You will see it in the output from mvn install at the compatibility-tests");
|
||||
System.out.println("... look for output from dependency-scan");
|
||||
|
||||
// our dependency scan used at the pom under compatibility-tests/pom.xml will generate these, example:
|
||||
// [INFO] dependency-scan setting: -DARTEMIS-140="/Users/someuser/....."
|
||||
// copy that into your IDE setting and you should be able to debug it
|
||||
}
|
||||
Assume.assumeTrue("Cannot run these tests, no classpath found", ok);
|
||||
String classPathValue = null;
|
||||
File file = new File("./target/" + name + ".cp");
|
||||
if (file.exists()) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Files.lines(file.toPath()).forEach((str) -> buffer.append(str));
|
||||
classPathValue = buffer.toString();
|
||||
}
|
||||
|
||||
ClassLoader loader = defineClassLoader(value);
|
||||
Assert.assertTrue("Cannot run compatibility tests, no classpath found on ./target/" + name + ".cp", classPathValue != null && !classPathValue.trim().equals(""));
|
||||
|
||||
ClassLoader loader = defineClassLoader(classPathValue);
|
||||
if (!forceNew) {
|
||||
// if we are forcing a new one, there's no point in caching it
|
||||
loaderMap.put(name, loader);
|
||||
|
|
Loading…
Reference in New Issue