Search in sources :

Example 1 with InternalMavenRunner

use of org.jenkins.tools.test.maven.InternalMavenRunner in project plugin-compat-tester by jenkinsci.

the class MultiParentCompileHook method action.

@Override
public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception {
    try {
        System.out.println("Executing multi-parent compile hook");
        PluginCompatTesterConfig config = (PluginCompatTesterConfig) moreInfo.get("config");
        MavenCoordinates core = (MavenCoordinates) moreInfo.get("core");
        runner = config.getExternalMaven() == null ? new InternalMavenRunner() : new ExternalMavenRunner(config.getExternalMaven());
        mavenConfig = getMavenConfig(config);
        File pluginDir = (File) moreInfo.get("pluginDir");
        System.out.println("Plugin dir is " + pluginDir);
        if (config.getLocalCheckoutDir() != null) {
            Path pluginSourcesDir = config.getLocalCheckoutDir().toPath();
            boolean isMultipleLocalPlugins = config.getIncludePlugins() != null && config.getIncludePlugins().size() > 1;
            // If not it must be located on the parent of the localCheckoutDir
            if (!isMultipleLocalPlugins) {
                pluginSourcesDir = pluginSourcesDir.getParent();
            }
            // Copy the file if it exists
            Files.walk(pluginSourcesDir, 1).filter(this::isEslintFile).forEach(eslintrc -> copy(eslintrc, pluginDir));
        }
        // We need to compile before generating effective pom overriding jenkins.version
        // only if the plugin is not already compiled
        boolean ranCompile = moreInfo.containsKey(OVERRIDE_DEFAULT_COMPILE) ? (boolean) moreInfo.get(OVERRIDE_DEFAULT_COMPILE) : false;
        if (!ranCompile) {
            compile(mavenConfig, pluginDir);
            moreInfo.put(OVERRIDE_DEFAULT_COMPILE, true);
        }
        System.out.println("Executed multi-parent compile hook");
        return moreInfo;
    // Exceptions get swallowed, so we print to console here and rethrow again
    } catch (Exception e) {
        System.out.println("Exception executing hook");
        System.out.println(e);
        throw e;
    }
}
Also used : Path(java.nio.file.Path) PluginCompatTesterConfig(org.jenkins.tools.test.model.PluginCompatTesterConfig) MavenCoordinates(org.jenkins.tools.test.model.MavenCoordinates) ExternalMavenRunner(org.jenkins.tools.test.maven.ExternalMavenRunner) InternalMavenRunner(org.jenkins.tools.test.maven.InternalMavenRunner) File(java.io.File) PomExecutionException(org.jenkins.tools.test.exception.PomExecutionException) IOException(java.io.IOException)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 PomExecutionException (org.jenkins.tools.test.exception.PomExecutionException)1 ExternalMavenRunner (org.jenkins.tools.test.maven.ExternalMavenRunner)1 InternalMavenRunner (org.jenkins.tools.test.maven.InternalMavenRunner)1 MavenCoordinates (org.jenkins.tools.test.model.MavenCoordinates)1 PluginCompatTesterConfig (org.jenkins.tools.test.model.PluginCompatTesterConfig)1