@Test public void testLegacyInheritance() throws Exception { File basedir = resources.getBasedir("plugin-descriptor/legacy-inheritance"); File legacyBasedir = new File(basedir, "legacy"); File pluginBasedir = new File(basedir, "plugin"); final MavenProject legacyProject = mojos.readMavenProject(legacyBasedir); addDependencies(legacyProject, "apache-plugin-annotations-jar", "maven-plugin-api-jar"); generatePluginDescriptor(legacyProject); mojos.assertBuildOutputs(legacyBasedir, "target/classes/META-INF/maven/plugin.xml", "target/classes/META-INF/m2e/lifecycle-mapping-metadata.xml"); rm(legacyBasedir, "target/classes/META-INF/takari/mojos.xml"); mojos.executeMojo(legacyProject, "jar"); final MavenProject pluginProject = mojos.readMavenProject(pluginBasedir); addDependencies(pluginProject, "apache-plugin-annotations-jar", "maven-plugin-api-jar"); addDependencies(pluginProject, new File(legacyBasedir, "target/plugin-descriptor-legacy-0.1.jar")); generatePluginDescriptor(pluginProject); mojos.assertBuildOutputs(pluginBasedir, "target/classes/META-INF/maven/plugin.xml", "target/classes/META-INF/m2e/lifecycle-mapping-metadata.xml"); assertFileContents(pluginBasedir, "expected/mojos.xml", "target/classes/META-INF/takari/mojos.xml"); assertFileContents(pluginBasedir, "expected/plugin.xml", "target/classes/META-INF/maven/plugin.xml"); }
@Override protected void executeMojo() throws MojoExecutionException { try { File mojosXml = new File(outputDirectory, PATH_MOJOS_XML); if (!mojosXml.isFile()) { return; } InputSet inputSet = context.newInputSet(); final Set<File> classpathJars = new LinkedHashSet<>(); final Set<File> classpathFiles = new LinkedHashSet<>(); for (Artifact artifact : dependencies) { if (artifact.getFile().isFile()) { classpathJars.add(inputSet.addInput(artifact.getFile())); } else if (artifact.getFile().isDirectory()) { File file = new File(artifact.getFile(), PATH_MOJOS_XML); if (file.canRead()) { classpathFiles.add(inputSet.addInput(file)); } } } inputSet.addInput(new File(outputDirectory, PATH_MOJOS_XML)); if (eclipseMetadataFile.isFile()) { inputSet.addInput(eclipseMetadataFile); } for (Resource resource : resources) { File otherEclipseMetadataFile = new File(resource.getDirectory(), PATH_METADATA_XML); if (otherEclipseMetadataFile.isFile()) { throw new MojoExecutionException(String.format("Unexpected Eclipse m2e metadata found %s. Did you mean to move it to %s", otherEclipseMetadataFile, eclipseMetadataFile)); } } inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_PLUGIN_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createPluginXml(output, mojosXml, classpathFiles, classpathJars); } }); inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_METADATA_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createEclipseMetadataXml(output, mojosXml, eclipseMetadataFile); } }); } catch (IOException e) { throw new MojoExecutionException("Could not create plugin descriptor", e); } }
PluginDescriptorMojo extends TakariLifecycleMojo { @Override protected void executeMojo() throws MojoExecutionException { try { File mojosXml = new File(outputDirectory, PATH_MOJOS_XML); if (!mojosXml.isFile()) { return; } InputSet inputSet = context.newInputSet(); final Set<File> classpathJars = new LinkedHashSet<>(); final Set<File> classpathFiles = new LinkedHashSet<>(); for (Artifact artifact : dependencies) { if (artifact.getFile().isFile()) { classpathJars.add(inputSet.addInput(artifact.getFile())); } else if (artifact.getFile().isDirectory()) { File file = new File(artifact.getFile(), PATH_MOJOS_XML); if (file.canRead()) { classpathFiles.add(inputSet.addInput(file)); } } } inputSet.addInput(new File(outputDirectory, PATH_MOJOS_XML)); if (eclipseMetadataFile.isFile()) { inputSet.addInput(eclipseMetadataFile); } for (Resource resource : resources) { File otherEclipseMetadataFile = new File(resource.getDirectory(), PATH_METADATA_XML); if (otherEclipseMetadataFile.isFile()) { throw new MojoExecutionException(String.format("Unexpected Eclipse m2e metadata found %s. Did you mean to move it to %s", otherEclipseMetadataFile, eclipseMetadataFile)); } } inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_PLUGIN_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createPluginXml(output, mojosXml, classpathFiles, classpathJars); } }); inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_METADATA_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createEclipseMetadataXml(output, mojosXml, eclipseMetadataFile); } }); } catch (IOException e) { throw new MojoExecutionException("Could not create plugin descriptor", e); } } }
PluginDescriptorMojo extends TakariLifecycleMojo { @Override protected void executeMojo() throws MojoExecutionException { try { File mojosXml = new File(outputDirectory, PATH_MOJOS_XML); if (!mojosXml.isFile()) { return; } InputSet inputSet = context.newInputSet(); final Set<File> classpathJars = new LinkedHashSet<>(); final Set<File> classpathFiles = new LinkedHashSet<>(); for (Artifact artifact : dependencies) { if (artifact.getFile().isFile()) { classpathJars.add(inputSet.addInput(artifact.getFile())); } else if (artifact.getFile().isDirectory()) { File file = new File(artifact.getFile(), PATH_MOJOS_XML); if (file.canRead()) { classpathFiles.add(inputSet.addInput(file)); } } } inputSet.addInput(new File(outputDirectory, PATH_MOJOS_XML)); if (eclipseMetadataFile.isFile()) { inputSet.addInput(eclipseMetadataFile); } for (Resource resource : resources) { File otherEclipseMetadataFile = new File(resource.getDirectory(), PATH_METADATA_XML); if (otherEclipseMetadataFile.isFile()) { throw new MojoExecutionException(String.format("Unexpected Eclipse m2e metadata found %s. Did you mean to move it to %s", otherEclipseMetadataFile, eclipseMetadataFile)); } } inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_PLUGIN_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createPluginXml(output, mojosXml, classpathFiles, classpathJars); } }); inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_METADATA_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createEclipseMetadataXml(output, mojosXml, eclipseMetadataFile); } }); } catch (IOException e) { throw new MojoExecutionException("Could not create plugin descriptor", e); } }  }
PluginDescriptorMojo extends TakariLifecycleMojo { @Override protected void executeMojo() throws MojoExecutionException { try { File mojosXml = new File(outputDirectory, PATH_MOJOS_XML); if (!mojosXml.isFile()) { return; } InputSet inputSet = context.newInputSet(); final Set<File> classpathJars = new LinkedHashSet<>(); final Set<File> classpathFiles = new LinkedHashSet<>(); for (Artifact artifact : dependencies) { if (artifact.getFile().isFile()) { classpathJars.add(inputSet.addInput(artifact.getFile())); } else if (artifact.getFile().isDirectory()) { File file = new File(artifact.getFile(), PATH_MOJOS_XML); if (file.canRead()) { classpathFiles.add(inputSet.addInput(file)); } } } inputSet.addInput(new File(outputDirectory, PATH_MOJOS_XML)); if (eclipseMetadataFile.isFile()) { inputSet.addInput(eclipseMetadataFile); } for (Resource resource : resources) { File otherEclipseMetadataFile = new File(resource.getDirectory(), PATH_METADATA_XML); if (otherEclipseMetadataFile.isFile()) { throw new MojoExecutionException(String.format("Unexpected Eclipse m2e metadata found %s. Did you mean to move it to %s", otherEclipseMetadataFile, eclipseMetadataFile)); } } inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_PLUGIN_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createPluginXml(output, mojosXml, classpathFiles, classpathJars); } }); inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_METADATA_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createEclipseMetadataXml(output, mojosXml, eclipseMetadataFile); } }); } catch (IOException e) { throw new MojoExecutionException("Could not create plugin descriptor", e); } }   }
PluginDescriptorMojo extends TakariLifecycleMojo { @Override protected void executeMojo() throws MojoExecutionException { try { File mojosXml = new File(outputDirectory, PATH_MOJOS_XML); if (!mojosXml.isFile()) { return; } InputSet inputSet = context.newInputSet(); final Set<File> classpathJars = new LinkedHashSet<>(); final Set<File> classpathFiles = new LinkedHashSet<>(); for (Artifact artifact : dependencies) { if (artifact.getFile().isFile()) { classpathJars.add(inputSet.addInput(artifact.getFile())); } else if (artifact.getFile().isDirectory()) { File file = new File(artifact.getFile(), PATH_MOJOS_XML); if (file.canRead()) { classpathFiles.add(inputSet.addInput(file)); } } } inputSet.addInput(new File(outputDirectory, PATH_MOJOS_XML)); if (eclipseMetadataFile.isFile()) { inputSet.addInput(eclipseMetadataFile); } for (Resource resource : resources) { File otherEclipseMetadataFile = new File(resource.getDirectory(), PATH_METADATA_XML); if (otherEclipseMetadataFile.isFile()) { throw new MojoExecutionException(String.format("Unexpected Eclipse m2e metadata found %s. Did you mean to move it to %s", otherEclipseMetadataFile, eclipseMetadataFile)); } } inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_PLUGIN_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createPluginXml(output, mojosXml, classpathFiles, classpathJars); } }); inputSet.aggregateIfNecessary(new File(outputDirectory, PATH_METADATA_XML), new InputAggregator() { @Override public void aggregate(Output<File> output, Iterable<File> inputs) throws IOException { createEclipseMetadataXml(output, mojosXml, eclipseMetadataFile); } }); } catch (IOException e) { throw new MojoExecutionException("Could not create plugin descriptor", e); } }    }