use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class TestAnalyzeDepMgt method setUp.
protected void setUp() throws Exception {
mojo = new AnalyzeDepMgt();
MavenProject project = new DependencyProjectStub();
stubFactory = new DependencyArtifactStubFactory(new File(""), false);
Set<Artifact> allArtifacts = stubFactory.getMixedArtifacts();
Set<Artifact> directArtifacts = stubFactory.getClassifiedArtifacts();
exclusionArtifact = stubFactory.getReleaseArtifact();
directArtifacts.add(exclusionArtifact);
ex = new Exclusion();
ex.setArtifactId(exclusionArtifact.getArtifactId());
ex.setGroupId(exclusionArtifact.getGroupId());
exclusion = new Dependency();
exclusion.setArtifactId(exclusionArtifact.getArtifactId());
exclusion.setGroupId(exclusionArtifact.getGroupId());
exclusion.setType(exclusionArtifact.getType());
exclusion.setClassifier("");
exclusion.setVersion("3.0");
exclusion.addExclusion(ex);
List<Dependency> list = new ArrayList<Dependency>();
list.add(exclusion);
depMgt = new DependencyManagement();
depMgt.setDependencies(list);
project.setArtifacts(allArtifacts);
project.setDependencyArtifacts(directArtifacts);
mojo.setProject(project);
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class TestUnpackMojo method getDependencyMgtList.
public List<Dependency> getDependencyMgtList(ArtifactItem item) {
Dependency dep = new Dependency();
dep.setArtifactId(item.getArtifactId());
dep.setClassifier(item.getClassifier());
dep.setGroupId(item.getGroupId());
dep.setType(item.getType());
dep.setVersion("3.0-SNAPSHOT");
Dependency dep2 = new Dependency();
dep2.setArtifactId(item.getArtifactId());
dep2.setClassifier("classifier");
dep2.setGroupId(item.getGroupId());
dep2.setType(item.getType());
dep2.setVersion("3.1");
List<Dependency> list = new ArrayList<Dependency>(2);
list.add(dep2);
list.add(dep);
return list;
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class TestCopyMojo method getDependencyMgtList.
public List<Dependency> getDependencyMgtList(ArtifactItem item) {
Dependency dep = new Dependency();
dep.setArtifactId(item.getArtifactId());
dep.setClassifier(item.getClassifier());
dep.setGroupId(item.getGroupId());
dep.setType(item.getType());
dep.setVersion("3.0-SNAPSHOT");
Dependency dep2 = new Dependency();
dep2.setArtifactId(item.getArtifactId());
dep2.setClassifier("classifier");
dep2.setGroupId(item.getGroupId());
dep2.setType(item.getType());
dep2.setVersion("3.1");
List<Dependency> list = new ArrayList<Dependency>(2);
list.add(dep2);
list.add(dep);
return list;
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class JLinkMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
String jLinkExec;
try {
jLinkExec = getJLinkExecutable();
} catch (IOException e) {
throw new MojoFailureException("Unable to find jlink command: " + e.getMessage(), e);
}
getLog().info("Toolchain in maven-jlink-plugin: jlink [ " + jLinkExec + " ]");
// TODO: Find a more better and cleaner way?
File jLinkExecuteable = new File(jLinkExec);
// Really Hacky...
File jLinkParent = jLinkExecuteable.getParentFile().getParentFile();
File jmodsFolder = new File(jLinkParent, "jmods");
getLog().debug(" Parent: " + jLinkParent.getAbsolutePath());
getLog().debug(" jmodsFolder: " + jmodsFolder.getAbsolutePath());
failIfParametersAreNotInTheirValidValueRanges();
deleteOutputDirectoryIfItAlreadyExists();
List<MavenProject> sortedProjects = getSession().getProjectDependencyGraph().getSortedProjects();
for (MavenProject mavenProject : sortedProjects) {
getLog().info("MavenProject: " + mavenProject.getBasedir());
}
List<Dependency> dependencies = getSession().getCurrentProject().getDependencies();
List<MavenProject> modulesToAdd = new ArrayList<>();
for (Dependency dependency : dependencies) {
if ("jmod".equals(dependency.getType())) {
MavenProject mp = findDependencyInProjects(dependency);
// TODO: What about module name != artifactId which has been
// defined in module-info.java file!
modulesToAdd.add(mp);
}
}
if (addModules == null) {
addModules = new ArrayList<>();
}
for (MavenProject mavenProject : modulesToAdd) {
addModules.add(mavenProject.getArtifactId());
}
if (modulePaths == null) {
modulePaths = new ArrayList<>();
}
// JDK mods folder
modulePaths.add(jmodsFolder.getAbsolutePath());
for (MavenProject mavenProject : modulesToAdd) {
File output = new File(mavenProject.getBuild().getDirectory(), "jmods");
modulePaths.add(output.getAbsolutePath());
}
// Synopsis
// Usage: jlink <options> --module-path <modulepath> --add-modules <mods> --output <path>
Commandline cmd;
try {
cmd = createJLinkCommandLine();
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage());
}
cmd.setExecutable(jLinkExec);
executeCommand(cmd, outputDirectory);
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class DependencyConvergenceReport method showVersionDetails.
private void showVersionDetails(DependencyNode projectNode, List<ReverseDependencyLink> depList, Sink sink) {
if (depList == null || depList.isEmpty()) {
return;
}
Dependency dependency = depList.get(0).getDependency();
String key = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getType() + ":" + dependency.getVersion();
serializeDependencyTree(projectNode, key, sink);
}
Aggregations