本文整理匯總了Java中org.apache.maven.model.Model.getDependencies方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.getDependencies方法的具體用法?Java Model.getDependencies怎麽用?Java Model.getDependencies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.model.Model
的用法示例。
在下文中一共展示了Model.getDependencies方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDependencyInList
import org.apache.maven.model.Model; //導入方法依賴的package包/類
/**
* Get dependency list from a maven model. Note: This is needed because
* {@link AbstractArtifactPomOperation#getDependencyInList(List, String, String)}
* does not accept a version as argument.
*/
private Dependency getDependencyInList(Model model, String groupId, String artifactId, String version) {
List<Dependency> dependencyList = model.getDependencies();
if (dependencyList == null || dependencyList.size() == 0) {
return null;
}
Dependency dependency = null;
for (Dependency d : dependencyList) {
if (d.getArtifactId().equals(artifactId) && d.getGroupId().equals(groupId)
&& d.getVersion().equals(version)) {
dependency = d;
break;
}
}
return dependency;
}
示例2: createProjectDependencyPomModel
import org.apache.maven.model.Model; //導入方法依賴的package包/類
private Model createProjectDependencyPomModel(Model processingPomModel) {
Model templateModel = new Model();
templateModel.setModelVersion(processingPomModel.getModelVersion());
templateModel.setGroupId("org.processing.idea");
templateModel.setArtifactId("core");
templateModel.setVersion("1.0.0");
List<Dependency> artifactDependencies = new ArrayList<>(6);
String joglVersion = null;
for (Dependency dependency : processingPomModel.getDependencies()) {
if (dependency.getGroupId().equals("org.jogamp.jogl") && dependency.getArtifactId().equals("jogl")) {
joglVersion = dependency.getVersion();
}
}
if (joglVersion == null) {
throw new IllegalStateException("Unable to determine JOGL version used for this build of Processing.");
}
Dependency core = new Dependency();
core.setGroupId("org.processing");
core.setArtifactId("core");
core.setVersion(version.toString());
artifactDependencies.add(core);
Dependency pdfExport = new Dependency();
pdfExport.setGroupId(VanillaLibrary.PDF_EXPORT.getGroupId());
pdfExport.setArtifactId(VanillaLibrary.PDF_EXPORT.getArtifactId());
pdfExport.setVersion(version.toString());
artifactDependencies.add(pdfExport);
Dependency serial = new Dependency();
serial.setGroupId(VanillaLibrary.SERIAL.getGroupId());
serial.setArtifactId(VanillaLibrary.SERIAL.getArtifactId());
serial.setVersion(version.toString());
artifactDependencies.add(serial);
Dependency network = new Dependency();
network.setGroupId(VanillaLibrary.NETWORK.getGroupId());
network.setArtifactId(VanillaLibrary.NETWORK.getArtifactId());
network.setVersion(version.toString());
artifactDependencies.add(network);
Dependency gluegenRt = new Dependency();
gluegenRt.setGroupId("org.jogamp.gluegen");
gluegenRt.setArtifactId("gluegen-rt-main");
gluegenRt.setVersion(joglVersion);
artifactDependencies.add(gluegenRt);
Dependency joglAllMain = new Dependency();
joglAllMain.setGroupId("org.jogamp.jogl");
joglAllMain.setArtifactId("jogl-all-main");
joglAllMain.setVersion(joglVersion);
artifactDependencies.add(joglAllMain);
if (SystemInfo.isMac) {
Dependency appleExtensions = new Dependency();
appleExtensions.setGroupId("com.apple");
appleExtensions.setArtifactId("AppleJavaExtensions");
appleExtensions.setVersion("LATEST");
artifactDependencies.add(appleExtensions);
}
templateModel.setDependencies(artifactDependencies);
return templateModel;
}
示例3: createDependencyReducedPom
import org.apache.maven.model.Model; //導入方法依賴的package包/類
private void createDependencyReducedPom( Set<String> artifactsToRemove )
throws IOException, DependencyGraphBuilderException, ProjectBuildingException
{
List<Dependency> dependencies = new ArrayList<Dependency>();
boolean modified = false;
List<Dependency> transitiveDeps = new ArrayList<Dependency>();
// NOTE: By using the getArtifacts() we get the completely evaluated artifacts
// including the system scoped artifacts with expanded values of properties used.
for ( Artifact artifact : project.getArtifacts() )
{
if ( "pom".equals( artifact.getType() ) )
{
// don't include pom type dependencies in dependency reduced pom
continue;
}
// promote
Dependency dep = createDependency( artifact );
// we'll figure out the exclusions in a bit.
transitiveDeps.add( dep );
}
List<Dependency> origDeps = project.getDependencies();
if ( promoteTransitiveDependencies )
{
origDeps = transitiveDeps;
}
Model model = project.getOriginalModel();
// MSHADE-185: We will remove all system scoped dependencies which usually
// have some kind of property usage. At this time the properties within
// such things are already evaluated.
List<Dependency> originalDependencies = model.getDependencies();
removeSystemScopedDependencies( artifactsToRemove, originalDependencies );
for ( Dependency d : origDeps )
{
dependencies.add( d );
String id = getId( d );
if ( artifactsToRemove.contains( id ) )
{
modified = true;
if ( keepDependenciesWithProvidedScope )
{
d.setScope( "provided" );
}
else
{
dependencies.remove( d );
}
}
}
// MSHADE-155
model.setArtifactId( shadedArtifactId );
// MSHADE-185: We will add those system scoped dependencies
// from the non interpolated original pom file. So we keep
// things like this: <systemPath>${tools.jar}</systemPath> intact.
addSystemScopedDependencyFromNonInterpolatedPom( dependencies, originalDependencies );
// Check to see if we have a reduction and if so rewrite the POM.
rewriteDependencyReducedPomIfWeHaveReduction( dependencies, modified, transitiveDeps, model );
}