@Test public void testInheritance_incremental() throws Exception { File basedir = resources.getBasedir("plugin-descriptor/incremental-inheritance"); File abstractBasedir = new File(basedir, "abstract"); File concreteBasedir = new File(basedir, "concrete"); final MavenProject abstractProject = mojos.readMavenProject(abstractBasedir); addDependencies(abstractProject, "apache-plugin-annotations-jar", "maven-plugin-api-jar"); final MavenProject concreteProject = mojos.readMavenProject(concreteBasedir); addDependencies(concreteProject, "apache-plugin-annotations-jar", "maven-plugin-api-jar"); addDependencies(concreteProject, new File(abstractBasedir, "target/classes")); generatePluginDescriptor(abstractProject); mojos.assertBuildOutputs(abstractBasedir, "target/classes/META-INF/maven/plugin.xml", "target/classes/META-INF/m2e/lifecycle-mapping-metadata.xml"); assertFileContents(abstractBasedir, "expected/mojos.xml", "target/classes/META-INF/takari/mojos.xml"); generatePluginDescriptor(concreteProject); mojos.assertBuildOutputs(concreteBasedir, "target/classes/META-INF/maven/plugin.xml", "target/classes/META-INF/m2e/lifecycle-mapping-metadata.xml"); assertFileContents(concreteBasedir, "expected/mojos.xml", "target/classes/META-INF/takari/mojos.xml"); assertFileContents(concreteBasedir, "expected/plugin.xml", "target/classes/META-INF/maven/plugin.xml"); mojos.executeMojo(abstractProject, "plugin-descriptor"); assertFileContents(abstractBasedir, "expected/mojos.xml", "target/classes/META-INF/takari/mojos.xml"); mojos.executeMojo(concreteProject, "plugin-descriptor"); assertFileContents(concreteBasedir, "expected/mojos.xml", "target/classes/META-INF/takari/mojos.xml"); assertFileContents(concreteBasedir, "expected/plugin.xml", "target/classes/META-INF/maven/plugin.xml"); cp(new File(abstractBasedir, "src/main/java/io/takari/lifecycle/uts/plugindescriptor"), "AbstractExternalMojo.java-changed", "AbstractExternalMojo.java"); generatePluginDescriptor(abstractProject); assertFileContents(abstractBasedir, "expected/mojos.xml-changed", "target/classes/META-INF/takari/mojos.xml"); generatePluginDescriptor(concreteProject); assertFileContents(concreteBasedir, "expected/mojos.xml-external-changed", "target/classes/META-INF/takari/mojos.xml"); assertFileContents(concreteBasedir, "expected/plugin.xml-external-changed", "target/classes/META-INF/maven/plugin.xml"); cp(new File(abstractBasedir, "src/main/java/io/takari/lifecycle/uts/plugindescriptor"), "AbstractExternalMojo.java-removed", "AbstractExternalMojo.java"); generatePluginDescriptor(abstractProject); generatePluginDescriptor(concreteProject); assertFileContents(concreteBasedir, "expected/mojos.xml-external-removed", "target/classes/META-INF/takari/mojos.xml"); assertFileContents(concreteBasedir, "expected/plugin.xml-external-removed", "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); } }    }