本文整理了Java中org.apache.maven.model.Model.addDependency()
方法的一些代码示例,展示了Model.addDependency()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.addDependency()
方法的具体详情如下:
包路径:org.apache.maven.model.Model
类名称:Model
方法名:addDependency
暂无
代码示例来源:origin: simpligility/android-maven-plugin
project.getModel().addDependency( dependency );
代码示例来源:origin: simpligility/android-maven-plugin
createSystemScopeDependency( artifact, libsJarFile, libsJarFile.getName() );
project.getModel().addDependency( dependency );
addedJarFromLibs = true;
代码示例来源:origin: takari/polyglot-maven
public void dependencies(Dependency... dependencies) {
asList(dependencies).forEach(dep -> {
model.addDependency(dep);
});
}
代码示例来源:origin: takari/polyglot-maven
public void dependencies(Consumer<DependencyDTO>... dependencies) {
if (dependencies != null) {
for (Consumer<DependencyDTO> consumer : Arrays.asList(dependencies)) {
DependencyDTO dto = new DependencyDTO();
consumer.accept(dto);
model.addDependency(dto.getDependency());
}
}
}
代码示例来源:origin: ru.yandex.qatools.clay/clay-maven-settings-builder
/**
* Method addDependency.
*
* @param dependency
*/
public FluentModelBuilder withDependency(Dependency dependency) {
model.addDependency(dependency);
return this;
}
代码示例来源:origin: com.buschmais.jqassistant.plugin/jqassistant.plugin.m2repo
@Override
public void addDependency(Dependency dependency) {
delegate.addDependency(dependency);
}
代码示例来源:origin: mulesoft/mule
public File getArtifactPomFile() {
if (artifactPomFile == null) {
checkArgument(!isEmpty(artifactId), "Filename cannot be empty");
final File tempFile = new File(getTempFolder(), artifactId + ".pom");
tempFile.deleteOnExit();
Model model = new Model();
model.setGroupId(getGroupId());
model.setArtifactId(getArtifactId());
model.setVersion(getVersion());
model.setModelVersion("4.0.0");
if (!sharedLibraries.isEmpty()) {
model.setBuild(new Build());
model.getBuild().setPlugins(singletonList(createMuleMavenPlugin()));
}
for (AbstractDependencyFileBuilder fileBuilderDependency : dependencies) {
model.addDependency(fileBuilderDependency.getAsMavenDependency());
}
artifactPomFile = new File(tempFile.getAbsolutePath());
try (FileOutputStream fileOutputStream = new FileOutputStream(artifactPomFile)) {
new MavenXpp3Writer().write(fileOutputStream, model);
} catch (IOException e) {
throw new MuleRuntimeException(e);
}
}
return artifactPomFile;
}
代码示例来源:origin: io.teecube.t3/t3-common
/**
* Add the Maven dependency to a POM file.
*
* @param pom
* @param dependency
* @throws IOException
* @throws XmlPullParserException
*/
public static void addDependency(File pom, Dependency dependency) throws IOException, XmlPullParserException {
Model model = getModelFromPOM(pom);
model.addDependency(dependency);
writeModelToPOM(model, pom);
}
代码示例来源:origin: org.eclipse.tycho/tycho-core
void addDependency(ArtifactDescriptor artifact) {
List<Dependency> dependencyList = new ArrayList<>();
if (artifact.getMavenProject() != null) {
dependencyList.addAll(newProjectDependencies(artifact));
} else {
dependencyList.addAll(newExternalDependencies(artifact));
}
Model model = project.getModel();
for (Dependency dependency : dependencyList) {
model.addDependency(dependency);
}
}
代码示例来源:origin: takari/polyglot-maven
dependency.setClassifier(dep.getClassifier());
model.addDependency(dependency);
代码示例来源:origin: org.wso2.maven/org.wso2.maven.capp
public void addDependencies(CAppArtifactDependency dependency) throws MojoExecutionException {
if (dependency.isDummyDependency()){
getDummyDependencies().add(dependency);
}else{
Map<String, CAppArtifactDependency> dependencyMap = getDependencyMap();
String dependencyId=dependency.getDependencyId();
if (!dependencyMap.containsKey(dependencyId)){
project.getModel().addDependency(dependency.getMavenDependency());
}
}
}
代码示例来源:origin: org.onehippo.cms7.essentials.sdk/implementation
/**
* Adds dependency if one does not exists. If dependency exists, only version will be updated
* (if version can be resolved and if provided dependency is higher than existing one)
*
* @param dependency instance of EssentialsDependency dependency
* @return true if dependency is added or already exists
*/
public static boolean addDependency(final EssentialsDependency dependency) {
final TargetPom targetPom = dependency.getDependencyTargetPom();
if (targetPom == TargetPom.INVALID) {
return false;
}
final Model model = ProjectUtils.getPomModel(targetPom);
if (model == null) {
log.warn("Pom model was null for targetPom: {}", targetPom);
return false;
}
if (!hasDependency(dependency)) {
final Dependency newDependency = dependency.createMavenDependency();
model.addDependency(newDependency);
final String pomPath = ProjectUtils.getPomPath(targetPom);
return writePom(pomPath, model);
}
return true;
}
代码示例来源:origin: org.kie.guvnor/guvnor-project-backend
public String toString(POM gavModel)
throws IOException {
Model model = new Model();
model.setGroupId(gavModel.getGav().getGroupId());
model.setArtifactId(gavModel.getGav().getArtifactId());
model.setVersion(gavModel.getGav().getVersion());
model.setModelVersion(gavModel.getModelVersion());
for (org.kie.guvnor.project.model.Repository repository : gavModel.getRepositories()) {
model.addRepository(fromClientModelToPom(repository));
}
for (org.kie.guvnor.project.model.Dependency dependency : gavModel.getDependencies()) {
model.addDependency(fromClientModelToPom(dependency));
}
StringWriter stringWriter = new StringWriter();
new MavenXpp3Writer().write(stringWriter, model);
return stringWriter.toString();
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-project-backend
public String toString(POM gavModel)
throws IOException {
Model model = new Model();
model.setGroupId(gavModel.getGav().getGroupId());
model.setArtifactId(gavModel.getGav().getArtifactId());
model.setVersion(gavModel.getGav().getVersion());
model.setModelVersion(gavModel.getModelVersion());
for (org.kie.workbench.common.services.project.service.model.Repository repository : gavModel.getRepositories()) {
model.addRepository(fromClientModelToPom(repository));
}
for (org.kie.workbench.common.services.project.service.model.Dependency dependency : gavModel.getDependencies()) {
model.addDependency(fromClientModelToPom(dependency));
}
StringWriter stringWriter = new StringWriter();
new MavenXpp3Writer().write(stringWriter, model);
return stringWriter.toString();
}
代码示例来源:origin: org.wso2.maven/org.wso2.maven.capp
protected void addDependencies(MavenProject artifactMavenProject, Artifact artifact, File projectLocation) {
getBundlesDataInfo(projectLocation, artifact);
List<LibraryArtifact> libraries = getBundlesDataInfo(null, artifact).getLibraries();
for (LibraryArtifact libraryArtifact : libraries) {
try {
String groupId = libraryArtifact.getGroupId();
String artifactId = libraryArtifact.getArtifactId();
String version = libraryArtifact.getVersion();
String scope = null;
String systemPath = null;
String type = null;
if (libraryArtifact.isLocal()){
scope = libraryArtifact.getScope();
systemPath = "${basedir}/"+FileUtils.getRelativePath(getProjectLocation(), libraryArtifact.getArtifactFile());
}
Dependency dependency = CAppMavenUtils.createDependency(groupId, artifactId,
version, scope, type, systemPath);
artifactMavenProject.getModel().addDependency(dependency);
} catch (MojoExecutionException e) {
getLog().error(e);
break;
}
}
}
代码示例来源:origin: org.commonjava.maven.cartographer/cartographer
private void addDependencyTo( final Model model, final VersionlessArtifactRef artifact, final VersionSpec spec,
final ProjectRef ga, final DependencyManagement depMgmt, final PomRequest dto )
{
final Dependency d = new Dependency();
d.setGroupId( ga.getGroupId() );
d.setArtifactId( ga.getArtifactId() );
d.setVersion( spec.renderStandard() );
if ( !"jar".equals( artifact.getType() ) )
{
d.setType( artifact.getType() );
}
if ( artifact.getClassifier() != null )
{
d.setClassifier( artifact.getClassifier() );
}
if ( dto.isGraphToManagedDeps() )
{
depMgmt.addDependency( d );
}
else
{
model.addDependency( d );
}
}
代码示例来源:origin: org.commonjava.cartographer/cartographer
private void addDependencyTo( final Model model, final VersionlessArtifactRef artifact, final VersionSpec spec,
final ProjectRef ga, final DependencyManagement depMgmt, final PomRequest dto )
{
final Dependency d = new Dependency();
d.setGroupId( ga.getGroupId() );
d.setArtifactId( ga.getArtifactId() );
d.setVersion( spec.renderStandard() );
if ( !"jar".equals( artifact.getType() ) )
{
d.setType( artifact.getType() );
}
if ( artifact.getClassifier() != null )
{
d.setClassifier( artifact.getClassifier() );
}
if ( dto.isGraphToManagedDeps() )
{
depMgmt.addDependency( d );
}
else
{
model.addDependency( d );
}
}
代码示例来源:origin: torquebox/jruby-maven-plugins
private boolean relocateIfNeeded(final MavenArtifact mart){
Model model = mart.getPom();
if (model.getDistributionManagement() != null) {
final Relocation relocation = model.getDistributionManagement()
.getRelocation();
if (relocation != null) {
String newGroupId = relocation.getGroupId() == null
? mart.getCoordinates().getGroupId()
: relocation.getGroupId();
String newArtifactId = relocation.getArtifactId() == null
? mart.getCoordinates().getArtifactId()
: relocation.getArtifactId();
String newVersion = relocation.getVersion() == null
? mart.getCoordinates().getVersion()
: relocation.getVersion();
Dependency dep = new Dependency();
dep.setArtifactId(newArtifactId);
dep.setGroupId(newGroupId);
dep.setVersion(newVersion);
dep.setType(model.getPackaging());
model.getDependencies().clear();
model.addDependency(dep);
model.setPackaging("pom");
return true;
}
}
return false;
}
代码示例来源:origin: org.onehippo.cms7.essentials.sdk/implementation
public static boolean upgradeToEnterpriseProject() {
if (isEnterpriseProject()) {
return true;
}
final Repository repository = new RepositoryRestful();
repository.setId("hippo-maven2-enterprise");
repository.setId("Hippo Enterprise Maven 2");
repository.setId("https://maven.onehippo.com/maven2-enterprise");
addRepository(repository);
final Model pomModel = ProjectUtils.getPomModel(TargetPom.PROJECT);
if (pomModel != null) {
final Parent parent = new Parent();
parent.setArtifactId(ProjectUtils.ENT_GROUP_ID);
parent.setGroupId(ProjectUtils.ENT_GROUP_ID);
pomModel.setParent(parent);
// add indicator:
final Model cmsModel = ProjectUtils.getPomModel(TargetPom.CMS);
final Dependency indicator = new Dependency();
indicator.setArtifactId("hippo-addon-edition-indicator");
indicator.setGroupId("com.onehippo.cms7");
cmsModel.addDependency(indicator);
writePom(ProjectUtils.getPomPath(TargetPom.CMS), cmsModel);
return writePom(ProjectUtils.getPomPath(TargetPom.PROJECT), pomModel);
}
return false;
}
代码示例来源:origin: org.onehippo.cms7.essentials/hippo-essentials-plugin-api-implementation
public static boolean upgradeToEnterpriseProject() {
if (isEnterpriseProject()) {
return true;
}
final Repository repository = new RepositoryRestful();
repository.setId("hippo-maven2-enterprise");
repository.setId("Hippo Enterprise Maven 2");
repository.setId("https://maven.onehippo.com/maven2-enterprise");
addRepository(repository);
final Model pomModel = ProjectUtils.getPomModel(TargetPom.PROJECT);
if (pomModel != null) {
final Parent parent = new Parent();
parent.setArtifactId(ProjectUtils.ENT_GROUP_ID);
parent.setGroupId(ProjectUtils.ENT_GROUP_ID);
pomModel.setParent(parent);
// add indicator:
final Model cmsModel = ProjectUtils.getPomModel(TargetPom.CMS);
final Dependency indicator = new Dependency();
indicator.setArtifactId("hippo-addon-edition-indicator");
indicator.setGroupId("com.onehippo.cms7");
cmsModel.addDependency(indicator);
writePom(ProjectUtils.getPomPath(TargetPom.CMS), cmsModel);
return writePom(ProjectUtils.getPomPath(TargetPom.PROJECT), pomModel);
}
return false;
}
内容来源于网络,如有侵权,请联系作者删除!