Java tutorial
package maus.eirik.mvn.plugin.delta; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.jdom2.Element; import java.io.File; import java.util.ArrayList; /** * Goal which touches a timestamp file. * * @goal touch * * @phase process-sources */ public class FetchAndExplodeReferenceVersionMojo extends AbstractMojo { /** * @parameter ${project} */ private MavenProject project; /** * Location of the file. * @parameter expression="${project.build.directory}" * @required */ private File outputDirectory; public void execute() throws MojoExecutionException { MavenProject project = createMavenChildProjectsWithTransitivesExcludedAndReferenceDataAdded(); } /** * Creates a maven project that will download referenced elements * @return */ private MavenProject createMavenChildProjectsWithTransitivesExcludedAndReferenceDataAdded() { Model model = new Model(); MavenProject project = new MavenProject(model); model.setParent(new Parent()); ArrayList<Dependency> dependencies = new ArrayList<Dependency>(); Dependency thisProjectDependency = new Dependency(); thisProjectDependency.setGroupId(this.project.getGroupId()); thisProjectDependency.setArtifactId(this.project.getArtifactId()); thisProjectDependency.setVersion(this.project.getVersion()); // exclude all transitive dependencies ArrayList<Exclusion> exclusions = new ArrayList<Exclusion>(); for (Object o : this.project.getCompileDependencies()) { Dependency d = (Dependency) o; Exclusion e = new Exclusion(); e.setGroupId(d.getGroupId()); e.setArtifactId(d.getArtifactId()); exclusions.add(e); } for (Object o : this.project.getTestDependencies()) { Dependency d = (Dependency) o; Exclusion e = new Exclusion(); e.setGroupId(d.getGroupId()); e.setArtifactId(d.getArtifactId()); exclusions.add(e); } thisProjectDependency.setExclusions(exclusions); dependencies.add(thisProjectDependency); model.setDependencies(dependencies); return project; } private String[] getReferenceVersionsAndClassifiers() { } }