本文整理了Java中org.apache.maven.model.Model.setDependencyManagement()
方法的一些代码示例,展示了Model.setDependencyManagement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.setDependencyManagement()
方法的具体详情如下:
包路径:org.apache.maven.model.Model
类名称:Model
方法名:setDependencyManagement
暂无
代码示例来源:origin: org.apache.maven/maven-project
private void assembleDependencyManagementInheritance( Model child, Model parent )
{
DependencyManagement parentDepMgmt = parent.getDependencyManagement();
DependencyManagement childDepMgmt = child.getDependencyManagement();
if ( parentDepMgmt != null )
{
if ( childDepMgmt == null )
{
child.setDependencyManagement( parentDepMgmt );
}
else
{
List childDeps = childDepMgmt.getDependencies();
Map mappedChildDeps = new TreeMap();
for ( Iterator it = childDeps.iterator(); it.hasNext(); )
{
Dependency dep = (Dependency) it.next();
mappedChildDeps.put( dep.getManagementKey(), dep );
}
for ( Iterator it = parentDepMgmt.getDependencies().iterator(); it.hasNext(); )
{
Dependency dep = (Dependency) it.next();
if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
{
childDepMgmt.addDependency( dep );
}
}
}
}
}
代码示例来源:origin: org.apache.maven/maven-project
model.setDependencyManagement( profileDepMgmt );
代码示例来源:origin: apache/maven
target.setDependencyManagement( depMgmt );
代码示例来源:origin: apache/maven
@SuppressWarnings( "unchecked" )
private void assembleDependencyManagementInheritance( Model child, Model parent )
{
DependencyManagement parentDepMgmt = parent.getDependencyManagement();
DependencyManagement childDepMgmt = child.getDependencyManagement();
if ( parentDepMgmt != null )
{
if ( childDepMgmt == null )
{
child.setDependencyManagement( parentDepMgmt );
}
else
{
List<Dependency> childDeps = childDepMgmt.getDependencies();
Map<String, Dependency> mappedChildDeps = new TreeMap<>();
for ( Dependency dep : childDeps )
{
mappedChildDeps.put( dep.getManagementKey(), dep );
}
for ( Dependency dep : parentDepMgmt.getDependencies() )
{
if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
{
childDepMgmt.addDependency( dep );
}
}
}
}
}
代码示例来源:origin: apache/maven
model.setDependencyManagement( parseDependencyManagement( parser, strict ) );
代码示例来源:origin: apache/maven
model.setDependencyManagement( parseDependencyManagement( parser, strict, source ) );
代码示例来源:origin: takari/polyglot-maven
public void dependencyManagement(Dependency... dependencies) {
if (model.getDependencyManagement() == null) {
DependencyManagement dependencyManagement = new DependencyManagement();
dependencyManagement.setDependencies(new ArrayList<Dependency>());
model.setDependencyManagement(dependencyManagement);
}
asList(dependencies).forEach(dep -> {
model.getDependencyManagement().addDependency(dep);
});
}
代码示例来源:origin: takari/polyglot-maven
public void dependencyManagement(Consumer<DependencyDTO>... dependencies) {
if (model.getDependencyManagement() == null) {
DependencyManagement dependencyManagement = new DependencyManagement();
dependencyManagement.setDependencies(new ArrayList<Dependency>());
model.setDependencyManagement(dependencyManagement);
}
if (dependencies != null) {
for (Consumer<DependencyDTO> consumer : Arrays.asList(dependencies)) {
DependencyDTO dto = new DependencyDTO();
consumer.accept(dto);
model.getDependencyManagement().addDependency(dto.getDependency());
}
}
}
代码示例来源:origin: mojohaus/flatten-maven-plugin
@Override
public void set( Model model, DependencyManagement value )
{
model.setDependencyManagement( value );
};
};
代码示例来源:origin: com.buschmais.jqassistant.plugin/jqassistant.plugin.m2repo
@Override
public void setDependencyManagement(DependencyManagement dependencyManagement) {
delegate.setDependencyManagement(dependencyManagement);
}
代码示例来源:origin: ru.yandex.qatools.clay/clay-maven-settings-builder
/**
* Set default dependency information for projects that inherit
* from this one. The
* dependencies in this section are not immediately
* resolved. Instead, when a POM derived
* from this one declares a dependency described by
* a matching groupId and artifactId, the
* version and other values from this section are
* used for that dependency if they were not
* already specified.
*
* @param dependencyManagement
*/
public FluentModelBuilder withDependencyManagement(DependencyManagement dependencyManagement) {
model.setDependencyManagement(dependencyManagement);
return this;
}
代码示例来源:origin: takari/polyglot-maven
model.setDependencyManagement( parseDependencyManagement( parser, strict ) );
代码示例来源:origin: takari/polyglot-maven
model.setDependencyManagement(depMan);
代码示例来源:origin: io.teecube.t3/t3-common
/**
* Remove the Maven dependency from a POM file (in management section).
*
* @param pom
* @param dependency
* @throws IOException
* @throws XmlPullParserException
*/
public static void removeDependencyManagement(File pom, Dependency dependency) throws IOException, XmlPullParserException {
Model model = getModelFromPOM(pom);
DependencyManagement dMgmt = model.getDependencyManagement();
if (dMgmt == null) {
model.setDependencyManagement(new DependencyManagement());
dMgmt = model.getDependencyManagement();
}
for (Iterator<Dependency> it = dMgmt.getDependencies().iterator(); it.hasNext();){
if (dependenciesEqual(it.next(), dependency)) {
it.remove();
}
}
writeModelToPOM(model, pom);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public void addDirectManagedDependency(final Dependency dep)
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
DependencyManagement depMan = pom.getDependencyManagement();
depMan = depMan != null ? depMan : new DependencyManagement();
List<Dependency> managedDependencies = MavenDependencyAdapter.fromMavenList(depMan.getDependencies());
ListIterator<Dependency> managedDepsIterator = managedDependencies.listIterator();
boolean found = false;
while (managedDepsIterator.hasNext())
{
Dependency managedDependency = managedDepsIterator.next();
if (Dependencies.areEquivalent(managedDependency, dep))
{
managedDepsIterator.set(dep);
found = true;
}
}
if (!found)
{
managedDependencies.add(dep);
}
depMan.setDependencies(MavenDependencyAdapter.toMavenList(managedDependencies));
pom.setDependencyManagement(depMan);
maven.setModel(pom);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public void removeManagedDependency(final Dependency manDep)
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
DependencyManagement depMan = pom.getDependencyManagement();
depMan = depMan != null ? depMan : new DependencyManagement();
List<Dependency> managedDependencies = MavenDependencyAdapter.fromMavenList(depMan.getDependencies());
List<Dependency> toBeRemoved = new ArrayList<>();
for (Dependency managedDependency : managedDependencies)
{
if (Dependencies.areEquivalent(managedDependency, manDep))
{
toBeRemoved.add(managedDependency);
}
}
managedDependencies.removeAll(toBeRemoved);
depMan.setDependencies(MavenDependencyAdapter.toMavenList(managedDependencies));
pom.setDependencyManagement(depMan);
maven.setModel(pom);
}
代码示例来源:origin: io.teecube.t3/t3-common
/**
* Add the Maven dependency to a POM file (in management section).
*
* @param pom
* @param dependency
* @throws IOException
* @throws XmlPullParserException
*/
public static void addDependencyManagement(File pom, Dependency dependency) throws IOException, XmlPullParserException {
Model model = getModelFromPOM(pom);
DependencyManagement dMgmt = model.getDependencyManagement();
if (dMgmt == null) {
model.setDependencyManagement(new DependencyManagement());
dMgmt = model.getDependencyManagement();
}
dMgmt.addDependency(dependency);
writeModelToPOM(model, pom);
}
代码示例来源:origin: io.teecube.t3/t3-common
/**
* Check whether a dependency exists in a POM (in management section).
*
* @param pom
* @param dependency
* @return true if the dependency exists in the management section of the
* POM
* @throws IOException
* @throws XmlPullParserException
*/
public static boolean dependencyExistsManagement(File pom, Dependency dependency) throws IOException, XmlPullParserException {
Model model = getModelFromPOM(pom);
DependencyManagement dMgmt = model.getDependencyManagement();
if (dMgmt == null) {
model.setDependencyManagement(new DependencyManagement());
dMgmt = model.getDependencyManagement();
}
return dependencyExists(dependency, dMgmt.getDependencies());
}
代码示例来源:origin: org.apache.maven/maven-ant-tasks
public void addConfiguredDependencyManagement( DependencyManagement dependencyManagement )
{
if ( getMavenProject().getDependencyManagement() == null )
{
// is is a bit disappointing that we have to access the encapsulated model to fix the NPE
getMavenProject().getModel().setDependencyManagement(new DependencyManagement());
}
getMavenProject().getDependencyManagement().setDependencies( dependencyManagement.getDependencies() );
}
代码示例来源:origin: reactiverse/vertx-maven-plugin
/**
* Method used to add the vert.x "vertx-stack-depchain" BOM
*
* @param model - the {@code {@link Model}}
*/
private void addVertxBom(Model model) {
Dependency vertxBom = dependency(VERTX_GROUP_ID, "vertx-stack-depchain", "${vertx.version}");
vertxBom.setType("pom");
vertxBom.setScope("import");
if (model.getDependencyManagement() != null) {
if (!MojoUtils.hasDependency(project, VERTX_GROUP_ID, "vertx-stack-depchain")) {
model.getDependencyManagement().addDependency(vertxBom);
}
} else {
DependencyManagement dm = new DependencyManagement();
dm.addDependency(vertxBom);
model.setDependencyManagement(dm);
}
}
内容来源于网络,如有侵权,请联系作者删除!