diff --git a/.github/workflows/pull_request_push_build.yml b/.github/workflows/pull_request_push_build.yml
index 7216096..447fa60 100644
--- a/.github/workflows/pull_request_push_build.yml
+++ b/.github/workflows/pull_request_push_build.yml
@@ -24,4 +24,4 @@ jobs:
distribution: ${{ matrix.jdk-distribution }}
cache: 'maven'
- name: Maven build
- run: mvn clean install -B -s build/settings.xml
+ run: mvn clean install -B -s build/settings.xml -Dorg.apache.maven.user-settings=build/settings.xml
diff --git a/mta-plugin/pom.xml b/mta-plugin/pom.xml
new file mode 100644
index 0000000..2ac8ff6
--- /dev/null
+++ b/mta-plugin/pom.xml
@@ -0,0 +1,53 @@
+
+ 4.0.0
+
+
+ org.jboss.windup.plugin
+ windup-maven-plugin-parent
+ 6.0.1-SNAPSHOT
+
+
+ mta-maven-plugin
+ maven-plugin
+
+ MTA Maven Plugin
+
+
+
+ org.jboss.windup
+ windup-bootstrap-mta
+
+
+ org.jboss.windup.rules
+ windup-rulesets-mta
+ ${version.windup-rulesets}
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+ maven-plugin-plugin
+
+ mta
+ true
+
+
+
+ mojo-descriptor
+
+ descriptor
+
+
+
+
+
+
+
+
diff --git a/src/it/settings.xml b/mta-plugin/src/it/settings.xml
similarity index 100%
rename from src/it/settings.xml
rename to mta-plugin/src/it/settings.xml
diff --git a/src/it/simple-it/pom.xml b/mta-plugin/src/it/simple-it/pom.xml
similarity index 100%
rename from src/it/simple-it/pom.xml
rename to mta-plugin/src/it/simple-it/pom.xml
diff --git a/src/it/simple-it/verify.groovy b/mta-plugin/src/it/simple-it/verify.groovy
similarity index 100%
rename from src/it/simple-it/verify.groovy
rename to mta-plugin/src/it/simple-it/verify.groovy
diff --git a/src/main/java/org/jboss/windup/plugin/WindupMojo.java b/mta-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java
similarity index 99%
rename from src/main/java/org/jboss/windup/plugin/WindupMojo.java
rename to mta-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java
index 8495ea7..cc41d88 100644
--- a/src/main/java/org/jboss/windup/plugin/WindupMojo.java
+++ b/mta-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java
@@ -181,7 +181,7 @@ public class WindupMojo extends AbstractMojo
private static final String WINDUP_RULES_GROUP_ID = "org.jboss.windup.rules";
- private static final String WINDUP_RULES_ARTIFACT_ID = "windup-rulesets";
+ private static final String WINDUP_RULES_ARTIFACT_ID = "windup-rulesets-mta";
public void execute() throws MojoExecutionException
diff --git a/src/main/resources/META-INF/beans.xml b/mta-plugin/src/main/resources/META-INF/beans.xml
similarity index 100%
rename from src/main/resources/META-INF/beans.xml
rename to mta-plugin/src/main/resources/META-INF/beans.xml
diff --git a/src/main/resources/META-INF/versions.properties b/mta-plugin/src/main/resources/META-INF/versions.properties
similarity index 100%
rename from src/main/resources/META-INF/versions.properties
rename to mta-plugin/src/main/resources/META-INF/versions.properties
diff --git a/src/main/resources/logging.properties b/mta-plugin/src/main/resources/logging.properties
similarity index 100%
rename from src/main/resources/logging.properties
rename to mta-plugin/src/main/resources/logging.properties
diff --git a/mta-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java b/mta-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java
new file mode 100644
index 0000000..60fa9cd
--- /dev/null
+++ b/mta-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java
@@ -0,0 +1,58 @@
+package org.jboss.windup.plugin;
+
+
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequestPopulator;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class WindupMojoTest extends AbstractMojoTestCase
+{
+ Properties versions = new Properties();
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ // required for mojo lookups to work
+ super.setUp();
+
+
+ try
+ {
+ final InputStream propsFile = WindupMojo.class.getClassLoader().getResourceAsStream("META-INF/versions.properties");
+ versions.load(propsFile);
+ }
+ catch (IOException ex)
+ {
+ final String msg = "Can't load the version definitions from classpath: META-INF/versions.properties";
+ throw new MojoExecutionException(msg, ex);
+ }
+ }
+
+ public void testNoWindupVersionParameter() throws Exception
+ {
+ File testPom = new File( getBasedir(),
+ "src/test/resources/mojoTestConfig.xml" );
+ assertNotNull(testPom);
+
+ WindupMojo mojo = (WindupMojo)lookupMojo("windup", testPom);
+ assertNotNull( mojo );
+ assertNull(mojo.getWindupVersion());
+ mojo.execute();
+
+
+ assertEquals(mojo.getWindupVersion(), versions.getProperty("version.windup"));
+ }
+
+}
\ No newline at end of file
diff --git a/mta-plugin/src/test/resources/mojoTestConfig.xml b/mta-plugin/src/test/resources/mojoTestConfig.xml
new file mode 100644
index 0000000..003408c
--- /dev/null
+++ b/mta-plugin/src/test/resources/mojoTestConfig.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ org.jboss.windup.plugin
+ mta-maven-plugin
+ 6.0.1-SNAPSHOT
+
+
+ run-windup
+ package
+
+ windup
+
+
+
+
+
+ org.apache
+
+
+ eap:7
+
+ src/main/java
+ target
+ true
+ false
+
+
+
+
+
\ No newline at end of file
diff --git a/mtr-plugin/pom.xml b/mtr-plugin/pom.xml
new file mode 100644
index 0000000..6b4fe08
--- /dev/null
+++ b/mtr-plugin/pom.xml
@@ -0,0 +1,53 @@
+
+ 4.0.0
+
+
+ org.jboss.windup.plugin
+ windup-maven-plugin-parent
+ 6.0.1-SNAPSHOT
+
+
+ mtr-maven-plugin
+ maven-plugin
+
+ MTR Maven Plugin
+
+
+
+ org.jboss.windup
+ windup-bootstrap-mtr
+
+
+ org.jboss.windup.rules
+ windup-rulesets-mtr
+ ${version.windup-rulesets}
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+ maven-plugin-plugin
+
+ mtr
+ true
+
+
+
+ mojo-descriptor
+
+ descriptor
+
+
+
+
+
+
+
+
diff --git a/mtr-plugin/src/it/settings.xml b/mtr-plugin/src/it/settings.xml
new file mode 100644
index 0000000..c8f77f0
--- /dev/null
+++ b/mtr-plugin/src/it/settings.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+ it-repo
+
+ true
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+
diff --git a/mtr-plugin/src/it/simple-it/pom.xml b/mtr-plugin/src/it/simple-it/pom.xml
new file mode 100644
index 0000000..a22e09c
--- /dev/null
+++ b/mtr-plugin/src/it/simple-it/pom.xml
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+
+ org.jboss.windup.plugin.it
+ simple-it
+ 6.0.1-SNAPSHOT
+
+ A simple IT verifying the basic use case.
+
+
+ UTF-8
+ 6.0.1-SNAPSHOT
+ 3.7.2.Final
+ ${project.basedir}/../../../
+ ${project.build.directory}/windup-report
+
+
+
+
+
+ org.jboss.windup.plugin
+ windup-maven-plugin
+ 6.0.1-SNAPSHOT
+
+
+ run-windup
+ package
+
+ windup
+
+
+
+
+
+ org.apache
+ com.acme
+
+
+ eap:7
+
+ ${inputDirectory}
+ ${outputDirectory}
+ true
+ false
+ ${version.windupcore}
+ false
+
+
+
+
+
+
diff --git a/mtr-plugin/src/it/simple-it/verify.groovy b/mtr-plugin/src/it/simple-it/verify.groovy
new file mode 100644
index 0000000..7b307c7
--- /dev/null
+++ b/mtr-plugin/src/it/simple-it/verify.groovy
@@ -0,0 +1,3 @@
+File touchFile = new File( basedir, "target/touch.txt" );
+
+assert touchFile.isFile()
diff --git a/mtr-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java b/mtr-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java
new file mode 100644
index 0000000..cf93da1
--- /dev/null
+++ b/mtr-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java
@@ -0,0 +1,490 @@
+/*
+* Copyright 2014 Red Hat, Inc. and/or its affiliates.
+*
+* Licensed under the Eclipse Public License version 1.0, available at
+* http://www.eclipse.org/legal/epl-v10.html
+*/
+
+package org.jboss.windup.plugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.settings.Settings;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.jboss.forge.furnace.Furnace;
+import org.jboss.forge.furnace.addons.AddonId;
+import org.jboss.forge.furnace.addons.AddonRegistry;
+import org.jboss.forge.furnace.impl.addons.AddonRepositoryImpl;
+import org.jboss.forge.furnace.manager.impl.AddonManagerImpl;
+import org.jboss.forge.furnace.manager.maven.MavenContainer;
+import org.jboss.forge.furnace.manager.maven.addon.MavenAddonDependencyResolver;
+import org.jboss.forge.furnace.manager.request.AddonActionRequest;
+import org.jboss.forge.furnace.manager.spi.AddonDependencyResolver;
+import org.jboss.forge.furnace.repositories.AddonRepositoryMode;
+import org.jboss.forge.furnace.se.FurnaceFactory;
+import org.jboss.forge.furnace.versions.SingleVersion;
+import org.jboss.forge.furnace.versions.Version;
+import org.jboss.forge.furnace.versions.Versions;
+import org.jboss.windup.config.AnalyzeKnownLibrariesOption;
+import org.jboss.windup.config.KeepWorkDirsOption;
+import org.jboss.windup.exec.WindupProcessor;
+import org.jboss.windup.exec.configuration.WindupConfiguration;
+import org.jboss.windup.exec.configuration.options.ExcludeTagsOption;
+import org.jboss.windup.exec.configuration.options.ExplodedAppInputOption;
+import org.jboss.windup.exec.configuration.options.IncludeTagsOption;
+import org.jboss.windup.exec.configuration.options.OverwriteOption;
+import org.jboss.windup.exec.configuration.options.SourceOption;
+import org.jboss.windup.exec.configuration.options.TargetOption;
+import org.jboss.windup.graph.GraphContext;
+import org.jboss.windup.graph.GraphContextFactory;
+import org.jboss.windup.rules.apps.diva.EnableTransactionAnalysisOption;
+import org.jboss.windup.rules.apps.java.config.ExcludePackagesOption;
+import org.jboss.windup.rules.apps.java.config.ScanPackagesOption;
+import org.jboss.windup.rules.apps.java.config.SourceModeOption;
+import org.jboss.windup.rules.apps.java.reporting.rules.EnableCompatibleFilesReportOption;
+import org.jboss.windup.rules.apps.tattletale.EnableTattletaleReportOption;
+import org.jboss.windup.util.PathUtil;
+import org.jboss.windup.util.ZipUtil;
+import org.jboss.windup.util.exception.WindupException;
+
+/**
+ * @author Samuel Tauil
+ * @author Ondrej Zizka
+ */
+@Mojo(name = "windup", requiresDependencyResolution = ResolutionScope.COMPILE, aggregator = true)
+@Execute(phase = LifecyclePhase.GENERATE_SOURCES)
+public class WindupMojo extends AbstractMojo
+{
+ private static final String VERSION_DEFINITIONS_FILE = "META-INF/versions.properties";
+
+ @Parameter(defaultValue = "${project.remotePluginRepositories}", readonly = true)
+ private List remoteRepos;
+
+ @Parameter(defaultValue = "${project.build.directory}")
+ private String buildDirectory;
+
+ /**
+ * Location of the generated report files.
+ */
+ @Parameter( alias = "output", property = "output", defaultValue = "${project.build.directory}/windup-report", required = true)
+ private String outputDirectory;
+
+ /**
+ * Location of the input file application.
+ */
+ @Parameter( alias="input", property = "input", required = true, defaultValue = "${project.basedir}/src/main" )
+ private String inputDirectory;
+
+ @Parameter( alias = "inputApplicationName", property = "inputApplicationName", required = false)
+ private String inputApplicationName;
+
+ /**
+ * Packages to be inspected by Windup.
+ */
+ @Parameter( alias="packages", property = "packages", required = true)
+ private List packages;
+
+ @Parameter( alias="excludePackages", property = "excludePackages", required = false)
+ private List excludePackages;
+
+ @Parameter( alias = "offline", property = "offline", required = true)
+ private Boolean offlineMode;
+
+ @Parameter( alias = "online", property = "online", required = false)
+ private Boolean onlineMode;
+
+ @Parameter( alias="sourceMode", property = "sourceMode", required = false, defaultValue = "true" )
+ private Boolean sourceMode;
+
+ @Parameter( alias="overwrite", property = "overwrite", required = false )
+ private Boolean overwrite;
+
+ @Parameter( alias="userIgnorePath", property = "userIgnorePath", required = false)
+ private String userIgnorePath;
+
+ @Parameter( alias="userRulesDirectory", property = "userRulesDirectory", required = false)
+ private String userRulesDirectory;
+
+ @Parameter( alias="includeTags", property = "includeTags", required = false )
+ private List includeTags;
+
+ @Parameter( alias="excludeTags", property = "excludeTags", required = false )
+ private List excludeTags;
+
+ @Parameter( alias="sourceTechnologies", property = "sourceTechnologies", required = false )
+ private List sources;
+
+ @Parameter( alias="targetTechnologies", property = "targetTechnologies", required = false)
+ private List targetTechnologies;
+
+
+ @Parameter( alias="windupVersion", property = "windupVersion", required = false )
+ private String windupVersion;
+
+ @Parameter( alias="windupRulesetsVersion", property = "windupRulesetsVersion", required = false )
+ private String windupRulesetsVersion;
+
+ @Parameter( alias="keepWorkDirs", property = "keepWorkDirs", required = false)
+ private Boolean keepWorkDirs;
+
+ @Parameter( alias="explodedApps", property = "explodedApps", required = false)
+ private Boolean explodedApps;
+
+ @Parameter( alias="exportCSV", property = "exportCSV", required = false)
+ private Boolean exportCSV;
+
+ @Parameter( alias="enableTattletale", property = "enableTattletale", required = false)
+ private Boolean enableTattletale;
+
+ @Parameter( alias="enableCompatibleFilesReport", property = "enableCompatibleFilesReport", required = false)
+ private Boolean enableCompatibleFilesReport;
+
+ @Parameter( alias="windupHome", property = "windupHome", required = false)
+ private String windupHome;
+
+ @Parameter( required = false)
+ private String customLoggingPropertiesFile;
+
+ @Parameter(alias = "analyzeKnownLibraries", property = "analyzeKnownLibraries", required = false)
+ private Boolean analyzeKnownLibraries;
+
+ @Parameter(alias = "enableTransactionAnalysis", property = "enableTransactionAnalysis", required = false)
+ private Boolean enableTransactionAnalysis;
+
+
+
+ private static final String WINDUP_RULES_GROUP_ID = "org.jboss.windup.rules";
+ private static final String WINDUP_RULES_ARTIFACT_ID = "windup-rulesets-mtr";
+
+
+ public void execute() throws MojoExecutionException
+ {
+
+
+ InputStream inputStream = null;
+
+ try
+ {
+
+
+ if (customLoggingPropertiesFile != null && !customLoggingPropertiesFile.equals(""))
+ {
+ try
+ {
+ //use file path supplied in pom.xml plugin configuration
+ inputStream = new FileInputStream(customLoggingPropertiesFile);
+ }
+ catch(IOException ioe)
+ {
+ //not throwing exception allows the default packaged properties to be used if the specified file from pom can't be loaded
+ Logger.getAnonymousLogger().severe("Could not load logging properties file specified in plugin configuration");
+ Logger.getAnonymousLogger().severe(ioe.getMessage());
+ }
+ }
+
+ if (inputStream == null)
+ {
+ //use default file packaged with windup-maven-plugin at src/main/resources
+ inputStream = WindupMojo.class.getClassLoader().getResourceAsStream("logging.properties");
+ }
+
+ LogManager.getLogManager().readConfiguration(inputStream);
+ inputStream.close();
+
+ }
+ catch (final IOException e)
+ {
+ Logger.getAnonymousLogger().severe("Could not load any logging.properties file");
+ Logger.getAnonymousLogger().severe(e.getMessage());
+ }
+
+
+
+ // If the user specified a windup home, use it instead of the custom rules
+ boolean windupHomeSpecified = StringUtils.isNotBlank(this.windupHome);
+
+ if (windupHomeSpecified)
+ System.setProperty(PathUtil.WINDUP_HOME, windupHome);
+ else
+ System.setProperty(PathUtil.WINDUP_HOME, Paths.get(buildDirectory, "winduphome").toString());
+
+ WindupConfiguration windupConfiguration = new WindupConfiguration();
+
+ windupConfiguration.addInputPath(Paths.get(inputDirectory));
+ if (this.inputApplicationName != null && this.inputApplicationName.trim().length() > 0)
+ windupConfiguration.addInputApplicationName(this.inputApplicationName);
+
+ windupConfiguration.setOutputDirectory(Paths.get(outputDirectory));
+
+ packages = normalizePackages(packages);
+ excludePackages = normalizePackages(excludePackages);
+ windupConfiguration.setOptionValue(ScanPackagesOption.NAME, packages);
+ windupConfiguration.setOptionValue(ExcludePackagesOption.NAME, excludePackages);
+
+ if (offlineMode != null && onlineMode == null)
+ onlineMode = !offlineMode.booleanValue();
+
+ windupConfiguration.setOnline(onlineMode == Boolean.TRUE);
+ windupConfiguration.setOptionValue(SourceModeOption.NAME, sourceMode == Boolean.TRUE);
+ windupConfiguration.setOptionValue(ExplodedAppInputOption.NAME, explodedApps == Boolean.TRUE);
+ windupConfiguration.setOptionValue(OverwriteOption.NAME, overwrite == Boolean.TRUE);
+
+ windupConfiguration.setOptionValue(IncludeTagsOption.NAME, includeTags);
+ windupConfiguration.setOptionValue(ExcludeTagsOption.NAME, excludeTags);
+ windupConfiguration.setOptionValue(SourceOption.NAME, sources);
+ windupConfiguration.setOptionValue(TargetOption.NAME, targetTechnologies);
+
+ windupConfiguration.setOptionValue(KeepWorkDirsOption.NAME, keepWorkDirs == Boolean.TRUE);
+ windupConfiguration.setOptionValue(EnableCompatibleFilesReportOption.NAME, enableCompatibleFilesReport);
+ windupConfiguration.setOptionValue(EnableTattletaleReportOption.NAME, enableTattletale == Boolean.TRUE);
+ windupConfiguration.setExportingCSV(exportCSV == Boolean.TRUE);
+
+ windupConfiguration.setOptionValue(AnalyzeKnownLibrariesOption.NAME, analyzeKnownLibraries == Boolean.TRUE);
+ windupConfiguration.setOptionValue(EnableTransactionAnalysisOption.NAME, enableTransactionAnalysis == Boolean.TRUE);
+
+ //Set up windupVersion here to ensure consistency
+ Properties versions;
+ try
+ {
+ versions = loadVersions(VERSION_DEFINITIONS_FILE);
+ }
+ catch (IOException ex)
+ {
+ final String msg = "Can't load the version definitions from classpath: " + VERSION_DEFINITIONS_FILE;
+ throw new MojoExecutionException(msg, ex);
+ }
+
+ final String furnaceVersion = versions.getProperty("version.furnace");
+ if(furnaceVersion == null)
+ throw new MojoExecutionException("Internal error: Version of Furnace was not defined.");
+
+ final String forgeVersion = versions.getProperty("version.forge");
+ if(forgeVersion == null)
+ throw new MojoExecutionException("Internal error: Version of Forge was not defined.");
+
+ //windupVersion passed in via parameter takes precedence over that in version.properties file
+ final String windupVersion_ = versions.getProperty("version.windup");
+ if(null == this.windupVersion && null != windupVersion_)
+ this.windupVersion = windupVersion_;
+ if(null == this.windupVersion)
+ throw new MojoExecutionException("Internal error: Version of Windup which should be used was not defined.");
+
+ // If they have specified a path to the windup home, then just use the rules from it instead of this process.
+ if (!windupHomeSpecified)
+ {
+ downloadAndUnzipRules();
+ }
+ windupConfiguration.addDefaultUserRulesDirectory(PathUtil.getWindupRulesDir());
+
+ if (userRulesDirectory != null && !Files.isDirectory(Paths.get(userRulesDirectory)))
+ {
+ try
+ {
+ Files.createDirectories(Paths.get(userRulesDirectory));
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ if (userRulesDirectory != null)
+ windupConfiguration.addDefaultUserRulesDirectory(Paths.get(userRulesDirectory));
+
+ if (userIgnorePath == null)
+ userIgnorePath = PathUtil.getWindupIgnoreDir().toString();
+ windupConfiguration.addDefaultUserIgnorePath(Paths.get(userIgnorePath));
+
+ Furnace furnace = createAndStartFurnace();
+ install("org.jboss.forge.furnace.container:simple," + furnaceVersion, furnace); // :simple instead of :cdi
+ install("org.jboss.forge.addon:core," + forgeVersion, furnace);
+ install("org.jboss.windup:windup-tooling," + this.windupVersion, furnace);
+ install("org.jboss.windup.rules.apps:windup-rules-java-project," + this.windupVersion, furnace);
+
+ if(this.enableTattletale == Boolean.TRUE)
+ install("org.jboss.windup.rules.apps:windup-rules-tattletale," + this.windupVersion, furnace);
+
+
+ AddonRegistry addonRegistry = furnace.getAddonRegistry();
+ WindupProcessor windupProcessor = addonRegistry.getServices(WindupProcessor.class).get();
+
+ GraphContextFactory graphContextFactory = addonRegistry.getServices(GraphContextFactory.class).get();
+
+ Path graphPath = windupConfiguration.getOutputDirectory().resolve("graph");
+ try (GraphContext graphContext = graphContextFactory.create(graphPath, true))
+ {
+ windupConfiguration.setGraphContext(graphContext);
+ getLog().info(
+ "\n\n=========================================================================================================================="
+ + "\n\n using Windup version: " + this.windupVersion
+ + "\n\n==========================================================================================================================\n");
+
+ windupProcessor.execute(windupConfiguration);
+ getLog().info(
+ "\n\n=========================================================================================================================="
+ + "\n\n Windup report created: " + windupConfiguration.getOutputDirectory().toAbsolutePath() + "/index.html"
+ + "\n\n==========================================================================================================================\n");
+
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void downloadAndUnzipRules()
+ {
+ MavenContainer mavenContainer = new MavenContainer();
+ RepositorySystem system = mavenContainer.getRepositorySystem();
+ Settings settings = mavenContainer.getSettings();
+ DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ // :[:[:]]:
+ if (windupRulesetsVersion == null)
+ {
+ windupRulesetsVersion = windupVersion;
+ }
+ artifactRequest.setRepositories(remoteRepos);
+ artifactRequest.setArtifact(new DefaultArtifact(WINDUP_RULES_GROUP_ID + ":" + WINDUP_RULES_ARTIFACT_ID + ":" + windupRulesetsVersion));
+ try
+ {
+ ArtifactResult artifactResult = mavenContainer.getRepositorySystem().resolveArtifact(session, artifactRequest);
+ Path outputDirectory = PathUtil.getWindupRulesDir();
+ if (!Files.isDirectory(outputDirectory))
+ Files.createDirectories(outputDirectory);
+ ZipUtil.unzipToFolder(artifactResult.getArtifact().getFile(), outputDirectory.toFile());
+ }
+ catch (ArtifactResolutionException | IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Furnace createAndStartFurnace()
+ {
+ // Create a Furnace instance. NOTE: This must be called only once
+ Furnace furnace = FurnaceFactory.getInstance();
+ // Add repository containing addons specified in pom.xml
+ furnace.addRepository(AddonRepositoryMode.MUTABLE, new File("target/addons"));
+
+ // Start Furnace in another thread
+ System.setProperty("INTERACTIVE", "false");
+ Future future = furnace.startAsync();
+ try
+ {
+ // Wait until Furnace is started and return
+ return future.get();
+ }
+ catch (InterruptedException | ExecutionException ex)
+ {
+ throw new WindupException("Failed to start Furnace: " + ex.getMessage(), ex);
+ }
+ }
+
+
+ /**
+ * TODO: Copied from Windup. Refactor.
+ */
+ private void install(String addonCoordinates, Furnace furnace)
+ {
+ Version runtimeAPIVersion = AddonRepositoryImpl.getRuntimeAPIVersion();
+ try
+ {
+ AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
+ AddonManagerImpl addonManager = new AddonManagerImpl(furnace, resolver);
+
+ AddonId addon = null;
+ // This allows windup --install maven
+ if (addonCoordinates.contains(","))
+ addon = AddonId.fromCoordinates(addonCoordinates);
+ else
+ addon = pickLatestAddonVersion(resolver, addonCoordinates, runtimeAPIVersion, addon);
+
+ if (addon == null)
+ throw new IllegalArgumentException("No compatible addon API version found for " + addonCoordinates + " for API " + runtimeAPIVersion);
+
+ AddonActionRequest request = addonManager.install(addon);
+ getLog().info("Requesting to install: " + request.toString());
+ request.perform();
+ getLog().info("Installation completed successfully.\n");
+ }
+ catch (Exception e)
+ {
+ getLog().error(e);
+ getLog().error("> Forge version [" + runtimeAPIVersion + "]");
+ }
+ }
+
+
+ private AddonId pickLatestAddonVersion(AddonDependencyResolver resolver, String addonCoordinates, Version runtimeAPIVersion, AddonId addon) throws IllegalArgumentException
+ {
+ AddonId[] versions = resolver.resolveVersions(addonCoordinates).get();
+ if (versions.length == 0)
+ throw new IllegalArgumentException("No Artifact version found for " + addonCoordinates);
+ for (int i = versions.length - 1; i >= 0; i--)
+ {
+ String apiVersion = resolver.resolveAPIVersion(versions[i]).get();
+ if (apiVersion != null && Versions.isApiCompatible(runtimeAPIVersion, SingleVersion.valueOf(apiVersion)))
+ return versions[i];
+ }
+ return null;
+ }
+
+ private Properties loadVersions(String path) throws IOException {
+ final InputStream propsFile = WindupMojo.class.getClassLoader().getResourceAsStream(path);
+ Properties props = new Properties();
+ props.load(propsFile);
+ return props;
+ }
+
+
+ /**
+ * Removes the .* suffix, which is expectable the users will use.
+ */
+ private List normalizePackages(List packages)
+ {
+ if (packages == null)
+ return null;
+
+ List result = new ArrayList<>(packages.size());
+ for (String pkg : packages)
+ {
+ if(pkg.endsWith(".*")){
+ getLog().warn("Warning: removing the .* suffix from the package prefix: " + pkg);
+ }
+ result.add(StringUtils.removeEndIgnoreCase(pkg, ".*"));
+ }
+
+ return packages;
+ }
+
+ public String getWindupVersion() {
+ return this.windupVersion;
+ }
+}
diff --git a/mtr-plugin/src/main/resources/META-INF/beans.xml b/mtr-plugin/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..ae0f4bf
--- /dev/null
+++ b/mtr-plugin/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/mtr-plugin/src/main/resources/META-INF/versions.properties b/mtr-plugin/src/main/resources/META-INF/versions.properties
new file mode 100644
index 0000000..c1eb77b
--- /dev/null
+++ b/mtr-plugin/src/main/resources/META-INF/versions.properties
@@ -0,0 +1,4 @@
+version.forge=${version.forge}
+version.furnace=${version.furnace}
+version.windup=${version.windupcore}
+version.rulesets=${version.windup-rulesets}
diff --git a/mtr-plugin/src/main/resources/logging.properties b/mtr-plugin/src/main/resources/logging.properties
new file mode 100644
index 0000000..765b519
--- /dev/null
+++ b/mtr-plugin/src/main/resources/logging.properties
@@ -0,0 +1,30 @@
+#
+# Copyright 2013-2014 Red Hat, Inc. and/or its affiliates.
+#
+# Licensed under the Eclipse Public License version 1.0, available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+
+# Additional loggers to configure (the root logger is always configured)
+#loggers=
+handlers=java.util.logging.ConsoleHandler
+.level=INFO
+#java.util.logging.ConsoleHandler.level=INFO
+
+#loggers=org.jboss.forge,org.jboss.weld,org.xnio,org.jboss.forge,org.ocpsoft.rewrite,org.jboss.windup.graph.GraphModelScanner,org.jboss.windup.reporting.xml.ClassificationHandler,org.jboss.windup.graph.GraphTyp$
+org.jboss.forge.level=SEVERE
+org.janusgraph.level=SEVERE
+org.janusgraph.diskstorage.berkeleyje.BerkeleyJEKeyValueStore.level=SEVERE
+org.janusgraph.diskstorage.berkeleyje.level=SEVERE
+org.jboss.weld.level=SEVERE
+org.xnio.level=SEVERE
+org.ocpsoft.rewrite.level=SEVERE
+org.jboss.windup.graph.GraphModelScanner.level=SEVERE
+org.jboss.windup.reporting.xml.ClassificationHandler.level=SEVERE
+org.jboss.windup.graph.GraphTypeManager.level=SEVERE
+org.jboss.windup.graph.GraphContextImpl.level=SEVERE
+org.jboss.windup.rules.files.FileMapping.level=SEVERE
+org.jboss.windup.exec.level=SEVERE
+org.jboss.windup.config.level=SEVERE
+com.thinkaurelius.level=SEVERE
+org.jboss.windup=INFO
diff --git a/mtr-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java b/mtr-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java
new file mode 100644
index 0000000..60fa9cd
--- /dev/null
+++ b/mtr-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java
@@ -0,0 +1,58 @@
+package org.jboss.windup.plugin;
+
+
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequestPopulator;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class WindupMojoTest extends AbstractMojoTestCase
+{
+ Properties versions = new Properties();
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ // required for mojo lookups to work
+ super.setUp();
+
+
+ try
+ {
+ final InputStream propsFile = WindupMojo.class.getClassLoader().getResourceAsStream("META-INF/versions.properties");
+ versions.load(propsFile);
+ }
+ catch (IOException ex)
+ {
+ final String msg = "Can't load the version definitions from classpath: META-INF/versions.properties";
+ throw new MojoExecutionException(msg, ex);
+ }
+ }
+
+ public void testNoWindupVersionParameter() throws Exception
+ {
+ File testPom = new File( getBasedir(),
+ "src/test/resources/mojoTestConfig.xml" );
+ assertNotNull(testPom);
+
+ WindupMojo mojo = (WindupMojo)lookupMojo("windup", testPom);
+ assertNotNull( mojo );
+ assertNull(mojo.getWindupVersion());
+ mojo.execute();
+
+
+ assertEquals(mojo.getWindupVersion(), versions.getProperty("version.windup"));
+ }
+
+}
\ No newline at end of file
diff --git a/mtr-plugin/src/test/resources/mojoTestConfig.xml b/mtr-plugin/src/test/resources/mojoTestConfig.xml
new file mode 100644
index 0000000..8fec2be
--- /dev/null
+++ b/mtr-plugin/src/test/resources/mojoTestConfig.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ org.jboss.windup.plugin
+ mtr-maven-plugin
+ 6.0.1-SNAPSHOT
+
+
+ run-windup
+ package
+
+ windup
+
+
+
+
+
+ org.apache
+
+
+ eap:7
+
+ src/main/java
+ target
+ true
+ false
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 44794f2..37126eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,11 +9,24 @@
org.jboss.windup.plugin
- windup-maven-plugin
+ windup-maven-plugin-parent
6.0.1-SNAPSHOT
- maven-plugin
+ pom
- Windup Maven Plugin
+ Windup Maven Plugin - Parent
+
+
+ UTF-8
+ 11
+ 11
+
+ 6.0.1-SNAPSHOT
+ 6.0.1-SNAPSHOT
+
+ 3.10.0.Final
+ 2.29.1.Final
+
http://windup.jboss.org
@@ -24,10 +37,6 @@
-
- 3.2
-
-
master
http://github.com/windup/windup-maven-plugin
@@ -68,19 +77,17 @@
https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
- UTF-8
- 11
- 11
- 6.0.1-SNAPSHOT
- 6.0.1-SNAPSHOT
-
- 3.10.0.Final
- 2.29.1.Final
-
+
+
+
+
+ maven-plugin-plugin
+ 3.6.0
+
+
+
+
@@ -91,11 +98,6 @@
pom
import
-
- org.jboss.windup.rules
- windup-rulesets
- ${version.windup-rulesets}
-
@@ -123,29 +125,21 @@
plexus-utils
3.4.1
-
-
+
+
junit
junit
4.13.2
test
-
-
-
org.jboss.windup
windup-tooling
forge-addon
-
-
- org.jboss.windup
- windup-bootstrap
-
@@ -154,10 +148,6 @@
zip
-
- org.jboss.windup.rules
- windup-rulesets
-
org.jboss.windup.rules.apps
windup-rules-java-project
@@ -173,8 +163,8 @@
-
-
+
+
org.jboss.forge.furnace
furnace-se
@@ -189,8 +179,8 @@
forge-addon
-
-
+
+
org.jboss.forge.addon
core
forge-addon
@@ -223,65 +213,50 @@
-
-
-
- src/main/resources
- true
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- 3.6.0
-
- windup
- true
-
-
-
- mojo-descriptor
-
- descriptor
-
-
-
-
-
-
-
run-integration-test
+
+
+
+ maven-invoker-plugin
+ 1.10
+
+ true
+ ${project.build.directory}/it
+
+ */pom.xml
+
+ verify
+ ${project.build.directory}/local-repo
+ src/it/settings.xml
+
+ clean
+ test-compile
+
+
+
+
+ integration-test
+
+ install
+ integration-test
+ verify
+
+
+
+
+
+
- org.apache.maven.plugins
maven-invoker-plugin
- 1.10
-
- true
- ${project.build.directory}/it
-
- */pom.xml
-
- verify
- ${project.build.directory}/local-repo
- src/it/settings.xml
-
- clean
- test-compile
-
-
+ false
integration-test
-
- install
- integration-test
- verify
-
+
@@ -305,5 +280,28 @@
+
+ windup
+
+
+ !skipThemeWindup
+
+
+
+ windup-plugin
+
+
+
+ mtr
+
+ mtr-plugin
+
+
+
+ mta
+
+ mta-plugin
+
+
diff --git a/windup-plugin/pom.xml b/windup-plugin/pom.xml
new file mode 100644
index 0000000..cae4ab6
--- /dev/null
+++ b/windup-plugin/pom.xml
@@ -0,0 +1,53 @@
+
+ 4.0.0
+
+
+ org.jboss.windup.plugin
+ windup-maven-plugin-parent
+ 6.0.1-SNAPSHOT
+
+
+ windup-maven-plugin
+ maven-plugin
+
+ Windup Maven Plugin
+
+
+
+ org.jboss.windup
+ windup-bootstrap-windup
+
+
+ org.jboss.windup.rules
+ windup-rulesets-windup
+ ${version.windup-rulesets}
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+ maven-plugin-plugin
+
+ windup
+ true
+
+
+
+ mojo-descriptor
+
+ descriptor
+
+
+
+
+
+
+
+
diff --git a/windup-plugin/src/it/settings.xml b/windup-plugin/src/it/settings.xml
new file mode 100644
index 0000000..c8f77f0
--- /dev/null
+++ b/windup-plugin/src/it/settings.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+ it-repo
+
+ true
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+
diff --git a/windup-plugin/src/it/simple-it/pom.xml b/windup-plugin/src/it/simple-it/pom.xml
new file mode 100644
index 0000000..a22e09c
--- /dev/null
+++ b/windup-plugin/src/it/simple-it/pom.xml
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+
+ org.jboss.windup.plugin.it
+ simple-it
+ 6.0.1-SNAPSHOT
+
+ A simple IT verifying the basic use case.
+
+
+ UTF-8
+ 6.0.1-SNAPSHOT
+ 3.7.2.Final
+ ${project.basedir}/../../../
+ ${project.build.directory}/windup-report
+
+
+
+
+
+ org.jboss.windup.plugin
+ windup-maven-plugin
+ 6.0.1-SNAPSHOT
+
+
+ run-windup
+ package
+
+ windup
+
+
+
+
+
+ org.apache
+ com.acme
+
+
+ eap:7
+
+ ${inputDirectory}
+ ${outputDirectory}
+ true
+ false
+ ${version.windupcore}
+ false
+
+
+
+
+
+
diff --git a/windup-plugin/src/it/simple-it/verify.groovy b/windup-plugin/src/it/simple-it/verify.groovy
new file mode 100644
index 0000000..7b307c7
--- /dev/null
+++ b/windup-plugin/src/it/simple-it/verify.groovy
@@ -0,0 +1,3 @@
+File touchFile = new File( basedir, "target/touch.txt" );
+
+assert touchFile.isFile()
diff --git a/windup-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java b/windup-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java
new file mode 100644
index 0000000..a1fe6f2
--- /dev/null
+++ b/windup-plugin/src/main/java/org/jboss/windup/plugin/WindupMojo.java
@@ -0,0 +1,490 @@
+/*
+* Copyright 2014 Red Hat, Inc. and/or its affiliates.
+*
+* Licensed under the Eclipse Public License version 1.0, available at
+* http://www.eclipse.org/legal/epl-v10.html
+*/
+
+package org.jboss.windup.plugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.settings.Settings;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.jboss.forge.furnace.Furnace;
+import org.jboss.forge.furnace.addons.AddonId;
+import org.jboss.forge.furnace.addons.AddonRegistry;
+import org.jboss.forge.furnace.impl.addons.AddonRepositoryImpl;
+import org.jboss.forge.furnace.manager.impl.AddonManagerImpl;
+import org.jboss.forge.furnace.manager.maven.MavenContainer;
+import org.jboss.forge.furnace.manager.maven.addon.MavenAddonDependencyResolver;
+import org.jboss.forge.furnace.manager.request.AddonActionRequest;
+import org.jboss.forge.furnace.manager.spi.AddonDependencyResolver;
+import org.jboss.forge.furnace.repositories.AddonRepositoryMode;
+import org.jboss.forge.furnace.se.FurnaceFactory;
+import org.jboss.forge.furnace.versions.SingleVersion;
+import org.jboss.forge.furnace.versions.Version;
+import org.jboss.forge.furnace.versions.Versions;
+import org.jboss.windup.config.AnalyzeKnownLibrariesOption;
+import org.jboss.windup.config.KeepWorkDirsOption;
+import org.jboss.windup.exec.WindupProcessor;
+import org.jboss.windup.exec.configuration.WindupConfiguration;
+import org.jboss.windup.exec.configuration.options.ExcludeTagsOption;
+import org.jboss.windup.exec.configuration.options.ExplodedAppInputOption;
+import org.jboss.windup.exec.configuration.options.IncludeTagsOption;
+import org.jboss.windup.exec.configuration.options.OverwriteOption;
+import org.jboss.windup.exec.configuration.options.SourceOption;
+import org.jboss.windup.exec.configuration.options.TargetOption;
+import org.jboss.windup.graph.GraphContext;
+import org.jboss.windup.graph.GraphContextFactory;
+import org.jboss.windup.rules.apps.diva.EnableTransactionAnalysisOption;
+import org.jboss.windup.rules.apps.java.config.ExcludePackagesOption;
+import org.jboss.windup.rules.apps.java.config.ScanPackagesOption;
+import org.jboss.windup.rules.apps.java.config.SourceModeOption;
+import org.jboss.windup.rules.apps.java.reporting.rules.EnableCompatibleFilesReportOption;
+import org.jboss.windup.rules.apps.tattletale.EnableTattletaleReportOption;
+import org.jboss.windup.util.PathUtil;
+import org.jboss.windup.util.ZipUtil;
+import org.jboss.windup.util.exception.WindupException;
+
+/**
+ * @author Samuel Tauil
+ * @author Ondrej Zizka
+ */
+@Mojo(name = "windup", requiresDependencyResolution = ResolutionScope.COMPILE, aggregator = true)
+@Execute(phase = LifecyclePhase.GENERATE_SOURCES)
+public class WindupMojo extends AbstractMojo
+{
+ private static final String VERSION_DEFINITIONS_FILE = "META-INF/versions.properties";
+
+ @Parameter(defaultValue = "${project.remotePluginRepositories}", readonly = true)
+ private List remoteRepos;
+
+ @Parameter(defaultValue = "${project.build.directory}")
+ private String buildDirectory;
+
+ /**
+ * Location of the generated report files.
+ */
+ @Parameter( alias = "output", property = "output", defaultValue = "${project.build.directory}/windup-report", required = true)
+ private String outputDirectory;
+
+ /**
+ * Location of the input file application.
+ */
+ @Parameter( alias="input", property = "input", required = true, defaultValue = "${project.basedir}/src/main" )
+ private String inputDirectory;
+
+ @Parameter( alias = "inputApplicationName", property = "inputApplicationName", required = false)
+ private String inputApplicationName;
+
+ /**
+ * Packages to be inspected by Windup.
+ */
+ @Parameter( alias="packages", property = "packages", required = true)
+ private List packages;
+
+ @Parameter( alias="excludePackages", property = "excludePackages", required = false)
+ private List excludePackages;
+
+ @Parameter( alias = "offline", property = "offline", required = true)
+ private Boolean offlineMode;
+
+ @Parameter( alias = "online", property = "online", required = false)
+ private Boolean onlineMode;
+
+ @Parameter( alias="sourceMode", property = "sourceMode", required = false, defaultValue = "true" )
+ private Boolean sourceMode;
+
+ @Parameter( alias="overwrite", property = "overwrite", required = false )
+ private Boolean overwrite;
+
+ @Parameter( alias="userIgnorePath", property = "userIgnorePath", required = false)
+ private String userIgnorePath;
+
+ @Parameter( alias="userRulesDirectory", property = "userRulesDirectory", required = false)
+ private String userRulesDirectory;
+
+ @Parameter( alias="includeTags", property = "includeTags", required = false )
+ private List includeTags;
+
+ @Parameter( alias="excludeTags", property = "excludeTags", required = false )
+ private List excludeTags;
+
+ @Parameter( alias="sourceTechnologies", property = "sourceTechnologies", required = false )
+ private List sources;
+
+ @Parameter( alias="targetTechnologies", property = "targetTechnologies", required = false)
+ private List targetTechnologies;
+
+
+ @Parameter( alias="windupVersion", property = "windupVersion", required = false )
+ private String windupVersion;
+
+ @Parameter( alias="windupRulesetsVersion", property = "windupRulesetsVersion", required = false )
+ private String windupRulesetsVersion;
+
+ @Parameter( alias="keepWorkDirs", property = "keepWorkDirs", required = false)
+ private Boolean keepWorkDirs;
+
+ @Parameter( alias="explodedApps", property = "explodedApps", required = false)
+ private Boolean explodedApps;
+
+ @Parameter( alias="exportCSV", property = "exportCSV", required = false)
+ private Boolean exportCSV;
+
+ @Parameter( alias="enableTattletale", property = "enableTattletale", required = false)
+ private Boolean enableTattletale;
+
+ @Parameter( alias="enableCompatibleFilesReport", property = "enableCompatibleFilesReport", required = false)
+ private Boolean enableCompatibleFilesReport;
+
+ @Parameter( alias="windupHome", property = "windupHome", required = false)
+ private String windupHome;
+
+ @Parameter( required = false)
+ private String customLoggingPropertiesFile;
+
+ @Parameter(alias = "analyzeKnownLibraries", property = "analyzeKnownLibraries", required = false)
+ private Boolean analyzeKnownLibraries;
+
+ @Parameter(alias = "enableTransactionAnalysis", property = "enableTransactionAnalysis", required = false)
+ private Boolean enableTransactionAnalysis;
+
+
+
+ private static final String WINDUP_RULES_GROUP_ID = "org.jboss.windup.rules";
+ private static final String WINDUP_RULES_ARTIFACT_ID = "windup-rulesets-windup";
+
+
+ public void execute() throws MojoExecutionException
+ {
+
+
+ InputStream inputStream = null;
+
+ try
+ {
+
+
+ if (customLoggingPropertiesFile != null && !customLoggingPropertiesFile.equals(""))
+ {
+ try
+ {
+ //use file path supplied in pom.xml plugin configuration
+ inputStream = new FileInputStream(customLoggingPropertiesFile);
+ }
+ catch(IOException ioe)
+ {
+ //not throwing exception allows the default packaged properties to be used if the specified file from pom can't be loaded
+ Logger.getAnonymousLogger().severe("Could not load logging properties file specified in plugin configuration");
+ Logger.getAnonymousLogger().severe(ioe.getMessage());
+ }
+ }
+
+ if (inputStream == null)
+ {
+ //use default file packaged with windup-maven-plugin at src/main/resources
+ inputStream = WindupMojo.class.getClassLoader().getResourceAsStream("logging.properties");
+ }
+
+ LogManager.getLogManager().readConfiguration(inputStream);
+ inputStream.close();
+
+ }
+ catch (final IOException e)
+ {
+ Logger.getAnonymousLogger().severe("Could not load any logging.properties file");
+ Logger.getAnonymousLogger().severe(e.getMessage());
+ }
+
+
+
+ // If the user specified a windup home, use it instead of the custom rules
+ boolean windupHomeSpecified = StringUtils.isNotBlank(this.windupHome);
+
+ if (windupHomeSpecified)
+ System.setProperty(PathUtil.WINDUP_HOME, windupHome);
+ else
+ System.setProperty(PathUtil.WINDUP_HOME, Paths.get(buildDirectory, "winduphome").toString());
+
+ WindupConfiguration windupConfiguration = new WindupConfiguration();
+
+ windupConfiguration.addInputPath(Paths.get(inputDirectory));
+ if (this.inputApplicationName != null && this.inputApplicationName.trim().length() > 0)
+ windupConfiguration.addInputApplicationName(this.inputApplicationName);
+
+ windupConfiguration.setOutputDirectory(Paths.get(outputDirectory));
+
+ packages = normalizePackages(packages);
+ excludePackages = normalizePackages(excludePackages);
+ windupConfiguration.setOptionValue(ScanPackagesOption.NAME, packages);
+ windupConfiguration.setOptionValue(ExcludePackagesOption.NAME, excludePackages);
+
+ if (offlineMode != null && onlineMode == null)
+ onlineMode = !offlineMode.booleanValue();
+
+ windupConfiguration.setOnline(onlineMode == Boolean.TRUE);
+ windupConfiguration.setOptionValue(SourceModeOption.NAME, sourceMode == Boolean.TRUE);
+ windupConfiguration.setOptionValue(ExplodedAppInputOption.NAME, explodedApps == Boolean.TRUE);
+ windupConfiguration.setOptionValue(OverwriteOption.NAME, overwrite == Boolean.TRUE);
+
+ windupConfiguration.setOptionValue(IncludeTagsOption.NAME, includeTags);
+ windupConfiguration.setOptionValue(ExcludeTagsOption.NAME, excludeTags);
+ windupConfiguration.setOptionValue(SourceOption.NAME, sources);
+ windupConfiguration.setOptionValue(TargetOption.NAME, targetTechnologies);
+
+ windupConfiguration.setOptionValue(KeepWorkDirsOption.NAME, keepWorkDirs == Boolean.TRUE);
+ windupConfiguration.setOptionValue(EnableCompatibleFilesReportOption.NAME, enableCompatibleFilesReport);
+ windupConfiguration.setOptionValue(EnableTattletaleReportOption.NAME, enableTattletale == Boolean.TRUE);
+ windupConfiguration.setExportingCSV(exportCSV == Boolean.TRUE);
+
+ windupConfiguration.setOptionValue(AnalyzeKnownLibrariesOption.NAME, analyzeKnownLibraries == Boolean.TRUE);
+ windupConfiguration.setOptionValue(EnableTransactionAnalysisOption.NAME, enableTransactionAnalysis == Boolean.TRUE);
+
+ //Set up windupVersion here to ensure consistency
+ Properties versions;
+ try
+ {
+ versions = loadVersions(VERSION_DEFINITIONS_FILE);
+ }
+ catch (IOException ex)
+ {
+ final String msg = "Can't load the version definitions from classpath: " + VERSION_DEFINITIONS_FILE;
+ throw new MojoExecutionException(msg, ex);
+ }
+
+ final String furnaceVersion = versions.getProperty("version.furnace");
+ if(furnaceVersion == null)
+ throw new MojoExecutionException("Internal error: Version of Furnace was not defined.");
+
+ final String forgeVersion = versions.getProperty("version.forge");
+ if(forgeVersion == null)
+ throw new MojoExecutionException("Internal error: Version of Forge was not defined.");
+
+ //windupVersion passed in via parameter takes precedence over that in version.properties file
+ final String windupVersion_ = versions.getProperty("version.windup");
+ if(null == this.windupVersion && null != windupVersion_)
+ this.windupVersion = windupVersion_;
+ if(null == this.windupVersion)
+ throw new MojoExecutionException("Internal error: Version of Windup which should be used was not defined.");
+
+ // If they have specified a path to the windup home, then just use the rules from it instead of this process.
+ if (!windupHomeSpecified)
+ {
+ downloadAndUnzipRules();
+ }
+ windupConfiguration.addDefaultUserRulesDirectory(PathUtil.getWindupRulesDir());
+
+ if (userRulesDirectory != null && !Files.isDirectory(Paths.get(userRulesDirectory)))
+ {
+ try
+ {
+ Files.createDirectories(Paths.get(userRulesDirectory));
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ if (userRulesDirectory != null)
+ windupConfiguration.addDefaultUserRulesDirectory(Paths.get(userRulesDirectory));
+
+ if (userIgnorePath == null)
+ userIgnorePath = PathUtil.getWindupIgnoreDir().toString();
+ windupConfiguration.addDefaultUserIgnorePath(Paths.get(userIgnorePath));
+
+ Furnace furnace = createAndStartFurnace();
+ install("org.jboss.forge.furnace.container:simple," + furnaceVersion, furnace); // :simple instead of :cdi
+ install("org.jboss.forge.addon:core," + forgeVersion, furnace);
+ install("org.jboss.windup:windup-tooling," + this.windupVersion, furnace);
+ install("org.jboss.windup.rules.apps:windup-rules-java-project," + this.windupVersion, furnace);
+
+ if(this.enableTattletale == Boolean.TRUE)
+ install("org.jboss.windup.rules.apps:windup-rules-tattletale," + this.windupVersion, furnace);
+
+
+ AddonRegistry addonRegistry = furnace.getAddonRegistry();
+ WindupProcessor windupProcessor = addonRegistry.getServices(WindupProcessor.class).get();
+
+ GraphContextFactory graphContextFactory = addonRegistry.getServices(GraphContextFactory.class).get();
+
+ Path graphPath = windupConfiguration.getOutputDirectory().resolve("graph");
+ try (GraphContext graphContext = graphContextFactory.create(graphPath, true))
+ {
+ windupConfiguration.setGraphContext(graphContext);
+ getLog().info(
+ "\n\n=========================================================================================================================="
+ + "\n\n using Windup version: " + this.windupVersion
+ + "\n\n==========================================================================================================================\n");
+
+ windupProcessor.execute(windupConfiguration);
+ getLog().info(
+ "\n\n=========================================================================================================================="
+ + "\n\n Windup report created: " + windupConfiguration.getOutputDirectory().toAbsolutePath() + "/index.html"
+ + "\n\n==========================================================================================================================\n");
+
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void downloadAndUnzipRules()
+ {
+ MavenContainer mavenContainer = new MavenContainer();
+ RepositorySystem system = mavenContainer.getRepositorySystem();
+ Settings settings = mavenContainer.getSettings();
+ DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ // :[:[:]]:
+ if (windupRulesetsVersion == null)
+ {
+ windupRulesetsVersion = windupVersion;
+ }
+ artifactRequest.setRepositories(remoteRepos);
+ artifactRequest.setArtifact(new DefaultArtifact(WINDUP_RULES_GROUP_ID + ":" + WINDUP_RULES_ARTIFACT_ID + ":" + windupRulesetsVersion));
+ try
+ {
+ ArtifactResult artifactResult = mavenContainer.getRepositorySystem().resolveArtifact(session, artifactRequest);
+ Path outputDirectory = PathUtil.getWindupRulesDir();
+ if (!Files.isDirectory(outputDirectory))
+ Files.createDirectories(outputDirectory);
+ ZipUtil.unzipToFolder(artifactResult.getArtifact().getFile(), outputDirectory.toFile());
+ }
+ catch (ArtifactResolutionException | IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Furnace createAndStartFurnace()
+ {
+ // Create a Furnace instance. NOTE: This must be called only once
+ Furnace furnace = FurnaceFactory.getInstance();
+ // Add repository containing addons specified in pom.xml
+ furnace.addRepository(AddonRepositoryMode.MUTABLE, new File("target/addons"));
+
+ // Start Furnace in another thread
+ System.setProperty("INTERACTIVE", "false");
+ Future future = furnace.startAsync();
+ try
+ {
+ // Wait until Furnace is started and return
+ return future.get();
+ }
+ catch (InterruptedException | ExecutionException ex)
+ {
+ throw new WindupException("Failed to start Furnace: " + ex.getMessage(), ex);
+ }
+ }
+
+
+ /**
+ * TODO: Copied from Windup. Refactor.
+ */
+ private void install(String addonCoordinates, Furnace furnace)
+ {
+ Version runtimeAPIVersion = AddonRepositoryImpl.getRuntimeAPIVersion();
+ try
+ {
+ AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
+ AddonManagerImpl addonManager = new AddonManagerImpl(furnace, resolver);
+
+ AddonId addon = null;
+ // This allows windup --install maven
+ if (addonCoordinates.contains(","))
+ addon = AddonId.fromCoordinates(addonCoordinates);
+ else
+ addon = pickLatestAddonVersion(resolver, addonCoordinates, runtimeAPIVersion, addon);
+
+ if (addon == null)
+ throw new IllegalArgumentException("No compatible addon API version found for " + addonCoordinates + " for API " + runtimeAPIVersion);
+
+ AddonActionRequest request = addonManager.install(addon);
+ getLog().info("Requesting to install: " + request.toString());
+ request.perform();
+ getLog().info("Installation completed successfully.\n");
+ }
+ catch (Exception e)
+ {
+ getLog().error(e);
+ getLog().error("> Forge version [" + runtimeAPIVersion + "]");
+ }
+ }
+
+
+ private AddonId pickLatestAddonVersion(AddonDependencyResolver resolver, String addonCoordinates, Version runtimeAPIVersion, AddonId addon) throws IllegalArgumentException
+ {
+ AddonId[] versions = resolver.resolveVersions(addonCoordinates).get();
+ if (versions.length == 0)
+ throw new IllegalArgumentException("No Artifact version found for " + addonCoordinates);
+ for (int i = versions.length - 1; i >= 0; i--)
+ {
+ String apiVersion = resolver.resolveAPIVersion(versions[i]).get();
+ if (apiVersion != null && Versions.isApiCompatible(runtimeAPIVersion, SingleVersion.valueOf(apiVersion)))
+ return versions[i];
+ }
+ return null;
+ }
+
+ private Properties loadVersions(String path) throws IOException {
+ final InputStream propsFile = WindupMojo.class.getClassLoader().getResourceAsStream(path);
+ Properties props = new Properties();
+ props.load(propsFile);
+ return props;
+ }
+
+
+ /**
+ * Removes the .* suffix, which is expectable the users will use.
+ */
+ private List normalizePackages(List packages)
+ {
+ if (packages == null)
+ return null;
+
+ List result = new ArrayList<>(packages.size());
+ for (String pkg : packages)
+ {
+ if(pkg.endsWith(".*")){
+ getLog().warn("Warning: removing the .* suffix from the package prefix: " + pkg);
+ }
+ result.add(StringUtils.removeEndIgnoreCase(pkg, ".*"));
+ }
+
+ return packages;
+ }
+
+ public String getWindupVersion() {
+ return this.windupVersion;
+ }
+}
diff --git a/windup-plugin/src/main/resources/META-INF/beans.xml b/windup-plugin/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..ae0f4bf
--- /dev/null
+++ b/windup-plugin/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/windup-plugin/src/main/resources/META-INF/versions.properties b/windup-plugin/src/main/resources/META-INF/versions.properties
new file mode 100644
index 0000000..c1eb77b
--- /dev/null
+++ b/windup-plugin/src/main/resources/META-INF/versions.properties
@@ -0,0 +1,4 @@
+version.forge=${version.forge}
+version.furnace=${version.furnace}
+version.windup=${version.windupcore}
+version.rulesets=${version.windup-rulesets}
diff --git a/windup-plugin/src/main/resources/logging.properties b/windup-plugin/src/main/resources/logging.properties
new file mode 100644
index 0000000..765b519
--- /dev/null
+++ b/windup-plugin/src/main/resources/logging.properties
@@ -0,0 +1,30 @@
+#
+# Copyright 2013-2014 Red Hat, Inc. and/or its affiliates.
+#
+# Licensed under the Eclipse Public License version 1.0, available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+
+# Additional loggers to configure (the root logger is always configured)
+#loggers=
+handlers=java.util.logging.ConsoleHandler
+.level=INFO
+#java.util.logging.ConsoleHandler.level=INFO
+
+#loggers=org.jboss.forge,org.jboss.weld,org.xnio,org.jboss.forge,org.ocpsoft.rewrite,org.jboss.windup.graph.GraphModelScanner,org.jboss.windup.reporting.xml.ClassificationHandler,org.jboss.windup.graph.GraphTyp$
+org.jboss.forge.level=SEVERE
+org.janusgraph.level=SEVERE
+org.janusgraph.diskstorage.berkeleyje.BerkeleyJEKeyValueStore.level=SEVERE
+org.janusgraph.diskstorage.berkeleyje.level=SEVERE
+org.jboss.weld.level=SEVERE
+org.xnio.level=SEVERE
+org.ocpsoft.rewrite.level=SEVERE
+org.jboss.windup.graph.GraphModelScanner.level=SEVERE
+org.jboss.windup.reporting.xml.ClassificationHandler.level=SEVERE
+org.jboss.windup.graph.GraphTypeManager.level=SEVERE
+org.jboss.windup.graph.GraphContextImpl.level=SEVERE
+org.jboss.windup.rules.files.FileMapping.level=SEVERE
+org.jboss.windup.exec.level=SEVERE
+org.jboss.windup.config.level=SEVERE
+com.thinkaurelius.level=SEVERE
+org.jboss.windup=INFO
diff --git a/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java b/windup-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java
similarity index 100%
rename from src/test/java/org/jboss/windup/plugin/WindupMojoTest.java
rename to windup-plugin/src/test/java/org/jboss/windup/plugin/WindupMojoTest.java
diff --git a/src/test/resources/mojoTestConfig.xml b/windup-plugin/src/test/resources/mojoTestConfig.xml
similarity index 100%
rename from src/test/resources/mojoTestConfig.xml
rename to windup-plugin/src/test/resources/mojoTestConfig.xml
diff --git a/src/test/resources/mojoTestConfigWithWindupVersion.xml b/windup-plugin/src/test/resources/mojoTestConfigWithWindupVersion.xml
similarity index 100%
rename from src/test/resources/mojoTestConfigWithWindupVersion.xml
rename to windup-plugin/src/test/resources/mojoTestConfigWithWindupVersion.xml