@Test public void testIncrementalDependencyChange() throws Exception { File basedir = resources.getBasedir("plugin-descriptor/incremental-dependency"); File dependency = new File(basedir, "dependency"); File plugin = new File(basedir, "plugin"); mojos.executeMojo(dependency, "compile"); MavenProject project = mojos.readMavenProject(plugin); addDependencies(project, "apache-plugin-annotations-jar", "maven-plugin-api-jar"); addDependencies(project, new File(dependency, "target/classes")); generatePluginDescriptor(project); mojos.assertBuildOutputs(plugin, "target/classes/META-INF/maven/plugin.xml", "target/classes/META-INF/m2e/lifecycle-mapping-metadata.xml"); cp(dependency, "src/main/java/io/takari/lifecycle/uts/plugindescriptor/ComponentClass.java-private-change", "src/main/java/io/takari/lifecycle/uts/plugindescriptor/ComponentClass.java"); mojos.executeMojo(dependency, "compile"); mojos.assertBuildOutputs(dependency, "target/classes/io/takari/lifecycle/uts/plugindescriptor/ComponentClass.class"); mojos.executeMojo(project, "compile", newParameter("compilerId", "jdt")); mojos.assertCarriedOverOutputs(plugin, "target/classes/io/takari/lifecycle/uts/plugindescriptor/BasicMojo.class"); mojos.executeMojo(project, "mojo-annotation-processor"); mojos.assertCarriedOverOutputs(plugin, "target/classes/META-INF/takari/mojos.xml"); mojos.executeMojo(project, "plugin-descriptor"); mojos.assertCarriedOverOutputs(plugin, "target/classes/META-INF/maven/plugin.xml", "target/classes/META-INF/m2e/lifecycle-mapping-metadata.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); } }    }