本文整理匯總了Java中org.apache.maven.model.Model.setArtifactId方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.setArtifactId方法的具體用法?Java Model.setArtifactId怎麽用?Java Model.setArtifactId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.model.Model
的用法示例。
在下文中一共展示了Model.setArtifactId方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ModelTree
import org.apache.maven.model.Model; //導入方法依賴的package包/類
/**
* This is a tree of Maven artifacts, which are represented by {@link Model} objects.
* The idea here is, given a list of Maven pom.xml {@link File} objects, create a tree
* based on dependency among them, but specifying explicitly which Maven artifact should
* be at the root of the tree. That means, if any artifact in the list is not a child,
* directly or indirectly, of the root artifact, then it will end up no being in the tree.
* <br>
* As a result of building this tree, it is possible to know, out of the initial pom.xml files list,
* which ones actually inherit, directly or not, from the root artifact. The result is retrieved
* by calling {@link #getPomFilesInTree()}
*
* @param rootGroupId the group id of the artifact that should be at the root of the tree
* @param rootArtifactId the artifact id of the artifact that should be at the root of the tree
* @param rootVersion the version of the artifact that should be at the root of the tree
* @param pomFiles a list of pom.xml files used to make the tree
*/
public ModelTree(String rootGroupId, String rootArtifactId, String rootVersion, List<File> pomFiles) {
Model rootModel = new Model();
rootModel.setGroupId(rootGroupId);
rootModel.setArtifactId(rootArtifactId);
rootModel.setVersion(rootVersion);
List<Model> models = new ArrayList<>();
models.add(rootModel);
for (File pomFile : pomFiles) {
models.add(createModel(pomFile));
}
// TODO we can comment this out in the future if we need this feature
// modelsNotInTree = add(models);
add(models);
}
示例2: pomFileWithDependencies
import org.apache.maven.model.Model; //導入方法依賴的package包/類
@And("^POM file with dependencies:$")
public void pomFileWithDependencies(List<MavenDependencySpec> dependencies) throws Throwable {
for (MavenDependencySpec dependency : dependencies) {
dependency.setExcludes(dependency.excludes);
}
Model model = new Model();
model.setModelVersion("4.0.0");
model.setGroupId("com.example");
model.setArtifactId("example-artifact");
model.setVersion("1.0.0-SNAPSHOT");
model.setPackaging("pom");
dependencies.forEach(model::addDependency);
Path pomFile = projectDir.resolve("pom.xml");
new MavenXpp3Writer().write(Files.newBufferedWriter(pomFile), model);
}
示例3: POMData
import org.apache.maven.model.Model; //導入方法依賴的package包/類
public POMData(ParentData parentData, String groupId, String artifactId, String versionId,
List<DependencyData>
dependencies, List<RepositoryData> repositories) throws IOException {
Model model = new Model();
parentData.write(model);
model.setGroupId(groupId);
model.setArtifactId(artifactId);
model.setVersion(versionId);
model.setModelVersion("4.0.0");
dependencies.forEach((dependencyData -> dependencyData.write(model)));
repositories.forEach((repositoryData -> repositoryData.write(model)));
this.dependencies = dependencies;
this.repositories = repositories;
this.groupId = groupId;
this.artifactId = artifactId;
this.version = versionId;
StringWriter writer = new StringWriter();
new MavenXpp3Writer().write(writer, model);
this.xml = writer.toString();
}
示例4: model
import org.apache.maven.model.Model; //導入方法依賴的package包/類
private ModelWrapper model(String projectName) {
Model parent = new Model();
parent.setArtifactId(projectName);
return new ModelWrapper(parent);
}
示例5: 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;
}
示例6: 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 );
}