org.apache.maven.model.Model类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.apache.maven.model.Model类的一些代码示例,展示了Model类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model类的具体详情如下:
包路径:org.apache.maven.model.Model
类名称:Model

Model介绍

[英]The <project> element is the root of the descriptor. The following table lists all of the possible child elements.
[中]<project>元素是描述符的根。下表列出了所有可能的子元素。

代码示例

代码示例来源:origin: org.apache.maven/maven-project

if ( child.getGroupId() == null )
  child.setGroupId( parent.getGroupId() );
if ( child.getVersion() == null )
  if ( child.getParent() != null )
    child.setVersion( child.getParent().getVersion() );
if ( child.getInceptionYear() == null )
  child.setInceptionYear( parent.getInceptionYear() );
if ( child.getUrl() == null )
  if ( parent.getUrl() != null )
    child.setUrl( appendPath( parent.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
    child.setUrl( parent.getUrl() );
if ( child.getIssueManagement() == null )
  child.setIssueManagement( parent.getIssueManagement() );
if ( child.getDescription() == null )
  child.setDescription( parent.getDescription() );

代码示例来源:origin: org.apache.maven/maven-project

Model result = new Model();
result.setArtifactId( src.getArtifactId() );
result.setBuild( cloneBuild( src.getBuild() ) );
result.setCiManagement( cloneCiManagement( src.getCiManagement() ) );
result.setContributors( cloneList( src.getContributors(), CONTRIBUTOR_CLONER ) );
result.setDescription( src.getDescription() );
result.setDevelopers( cloneList( src.getDevelopers(), DEVELOPER_CLONER ) );
result.setGroupId( src.getGroupId() );
result.setInceptionYear( src.getInceptionYear() );
result.setIssueManagement( cloneIssueManagement( src.getIssueManagement() ) );
result.setLicenses( cloneList( src.getLicenses(), LICENSE_CLONER ) );
result.setMailingLists( cloneList( src.getMailingLists(), MAILING_LIST_CLONER ) );
result.setModelVersion( src.getModelVersion() );
result.setName( src.getName() );
result.setOrganization( cloneOrganization( src.getOrganization() ) );
result.setPackaging( src.getPackaging() );
result.setParent( cloneParent( src.getParent() ) );
result.setPrerequisites( clonePrerequisites( src.getPrerequisites() ) );
result.setProfiles( cloneList( src.getProfiles(), PROFILE_CLONER ) );
result.setScm( cloneScm( src.getScm() ) );
result.setUrl( src.getUrl() );
result.setVersion( src.getVersion() );

代码示例来源:origin: org.apache.maven/maven-project

public void injectDefaults( Model model )
{
  injectDependencyDefaults( model.getDependencies(), model.getDependencyManagement() );
  if ( model.getBuild() != null )
  {
    injectPluginDefaults( model.getBuild(), model.getBuild().getPluginManagement() );
  }
}

代码示例来源:origin: apache/maven

private static String getKey( Model model )
{
  return "project>" + model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion();
}

代码示例来源:origin: apache/maven

protected void mergeModel_ArtifactId( Model target, Model source, boolean sourceDominant,
                   Map<Object, Object> context )
{
  String src = source.getArtifactId();
  if ( src != null )
  {
    if ( sourceDominant || target.getArtifactId() == null )
    {
      target.setArtifactId( src );
      target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
    }
  }
}

代码示例来源:origin: org.apache.maven/maven-project

public MavenProject()
{
  Model model = new Model();
  
  model.setGroupId( EMPTY_PROJECT_GROUP_ID );
  model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID );
  model.setVersion( EMPTY_PROJECT_VERSION );
  
  this.setModel( model );
}

代码示例来源:origin: org.apache.maven/maven-project

public void inject( Profile profile, Model model )
{
  model.setDependencies( injectDependencies( profile.getDependencies(), model.getDependencies() ) );
  injectModules( profile, model );
  model.setRepositories( ModelUtils.mergeRepositoryLists( profile.getRepositories(), model.getRepositories() ) );
  model.setPluginRepositories( ModelUtils.mergeRepositoryLists( profile.getPluginRepositories(), model
    .getPluginRepositories() ) );
  injectReporting( profile, model );
  injectDependencyManagement( profile, model );
  injectDistributionManagement( profile, model );
  injectBuild( profile, model );
  Properties props = new Properties();
  props.putAll( model.getProperties() );
  props.putAll( profile.getProperties() );
  model.setProperties( props );
}

代码示例来源:origin: apache/maven

Model tmpModel = rawModel.clone();
  currentData.setModel( tmpModel );
  profileActivationContext.setProjectProperties( tmpModel.getProperties() );
  List<Profile> activePomProfiles = profileSelector.getActiveProfiles( rawModel.getProfiles(),
                                     profileActivationContext, problems );
  currentData.setActiveProfiles( activePomProfiles );
    currentData.setGroupId( currentData.getRawModel().getGroupId() == null ? parentData.getGroupId()
                                       : currentData.getRawModel()
                                         .getGroupId() );
    currentData.setVersion( currentData.getRawModel().getVersion() == null ? parentData.getVersion()
                                       : currentData.getRawModel()
                                         .getVersion() );
    currentData.setArtifactId( currentData.getRawModel().getArtifactId() );
    parentIds.add( currentData.getId() );
if ( resultModel.getParent() != null )
  parentData.setVersion( interpolatedParent.getVersion() );
resultData.setGroupId( resultModel.getGroupId() );
resultData.setArtifactId( resultModel.getArtifactId() );
resultData.setVersion( resultModel.getVersion() );

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public CompilerVersion getSourceCompilerVersion()
{
 MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
 Model pom = maven.getModel();
 String sourceVersion = pom.getProperties().getProperty(MAVEN_COMPILER_SOURCE_KEY);
 return sourceVersion != null ? CompilerVersion.getValue(sourceVersion) : DEFAULT_COMPILER_VERSION;
}

代码示例来源:origin: org.apache.maven/maven-project

Properties modelProperties = model.getProperties();
if ( modelProperties != null )
  timestampFormat = modelProperties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY, timestampFormat );

代码示例来源:origin: apache/maven

@Override
public void assembleModelInheritance( Model child, Model parent, ModelBuildingRequest request,
                   ModelProblemCollector problems )
{
  Map<Object, Object> hints = new HashMap<>();
  String childPath = child.getProperties().getProperty( CHILD_DIRECTORY_PROPERTY, child.getArtifactId() );
  hints.put( CHILD_DIRECTORY, childPath );
  hints.put( MavenModelMerger.CHILD_PATH_ADJUSTMENT, getChildPathAdjustment( child, parent, childPath ) );
  merger.merge( child, parent, false, hints );
}

代码示例来源:origin: SonarSource/sonar-scanner-maven

private void configureModules(List<MavenProject> mavenProjects, Map<MavenProject, Map<String, String>> propsByModule)
 throws MojoExecutionException {
 for (MavenProject pom : mavenProjects) {
  boolean skipped = "true".equals(pom.getModel().getProperties().getProperty("sonar.skip"));
  if (skipped) {
   log.info("Module " + pom + " skipped by property 'sonar.skip'");
   continue;
  }
  propsByModule.put(pom, computeSonarQubeProperties(pom));
 }
}

代码示例来源:origin: org.nuiton/maven-helper-plugin

@Override
protected void doAction() throws Exception {
  Properties properties = project.getModel().getProperties();
  for (Map.Entry<Property, String> entry :
      propertiesToTreate.entrySet()) {
    Property key = entry.getKey();
    String propertyValue = key.getSecret(server);
    String propertyTargetName = entry.getValue();
    if (isVerbose()) {
      getLog().info("will decrypt [" + key + "] : " + propertyValue);
    }
    propertyValue = sec.decrypt(propertyValue);
    getLog().info("export server [" + serverId + "] " + key.name() +
           " in ${" + propertyTargetName + "}");
    properties.setProperty(propertyTargetName, propertyValue);
  }
}

代码示例来源:origin: me.escoffier.forge/vertx-forge-addon

public static void addPropertyToProject(Project project, String key, String value) {
 MavenFacet maven = project.getFacet(MavenFacet.class);
 Model pom = maven.getModel();
 Properties properties = pom.getProperties();
 properties.setProperty(key, value);
 maven.setModel(pom);
}

代码示例来源:origin: apache/maven

final ModelProblemCollector problems )
Properties modelProperties = model.getProperties();
if ( config.getSystemProperties().containsKey( REVISION_PROPERTY ) )
  modelProperties.put( REVISION_PROPERTY, config.getSystemProperties().get( REVISION_PROPERTY ) );
if ( config.getSystemProperties().containsKey( CHANGELIST_PROPERTY ) )

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public MavenMetadataFacet setDirectProperty(final String name, final String value)
{
 MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
 Model pom = maven.getModel();
 Properties properties = pom.getProperties();
 properties.put(name, value);
 maven.setModel(pom);
 return this;
}

代码示例来源:origin: org.apache.maven/maven-project

superProjectProfileManager.addProfiles( superModel.getProfiles() );
MavenProject superProject = new MavenProject( superModel );
superProject.setActiveProfiles( activeProfiles );
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
Model previous = superProject.getModel();
ModelUtils.mergeDuplicatePluginDefinitions( project.getModel().getBuild() );
  Build build = project.getBuild();
  project.addCompileSourceRoot( build.getSourceDirectory() );
  project.addScriptSourceRoot( build.getScriptSourceDirectory() );
  project.addTestCompileSourceRoot( build.getTestSourceDirectory() );

代码示例来源:origin: danielflower/multi-module-maven-release-plugin

private List<String> alterModel(MavenProject project, String newVersion) {
  Model originalModel = project.getOriginalModel();
  originalModel.setVersion(newVersion);
  String searchingFrom = project.getArtifactId();
  MavenProject parent = project.getParent();
  if (parent != null && isSnapshot(parent.getVersion())) {
    try {
      ReleasableModule parentBeingReleased = reactor.find(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
      originalModel.getParent().setVersion(parentBeingReleased.getVersionToDependOn());
      log.debug(" Parent " + parentBeingReleased.getArtifactId() + " rewritten to version " + parentBeingReleased.getVersionToDependOn());
    } catch (UnresolvedSnapshotDependencyException e) {
      errors.add("The parent of " + searchingFrom + " is " + e.artifactId + " " + e.version);
  Properties projectProperties = project.getProperties();
  for (Dependency dependency : originalModel.getDependencies()) {
    String version = dependency.getVersion();
    if (isSnapshot(resolveVersion(version, projectProperties))) {
      log.debug(" Dependency on " + dependency.getArtifactId() + " kept at version " + dependency.getVersion());
  for (Plugin plugin : project.getModel().getBuild().getPlugins()) {
    String version = plugin.getVersion();
    if (isSnapshot(resolveVersion(version, projectProperties))) {
      if (!isMultiModuleReleasePlugin(plugin)) {
        errors.add(searchingFrom + " references plugin " + plugin.getArtifactId() + " " + version);

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public boolean isInstalled()
{
 MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
 Model pom = maven.getModel();
 Properties properties = pom.getProperties();
 List<String> keys = Arrays.asList(MAVEN_COMPILER_SOURCE_KEY, MAVEN_COMPILER_TARGET_KEY,
      MAVEN_COMPILER_ENCODING_KEY);
 return properties.keySet().containsAll(keys);
}

代码示例来源:origin: org.apache.maven/maven-project

validateStringNotEmpty( "modelVersion", result, model.getModelVersion() );
validateId( "groupId", result, model.getGroupId() );
validateId( "artifactId", result, model.getArtifactId() );
validateStringNotEmpty( "packaging", result, model.getPackaging() );
if ( !model.getModules().isEmpty() && !"pom".equals( model.getPackaging() ) )
  result.addMessage( "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " +
      "require 'pom' as packaging." );
Parent parent = model.getParent();
if ( parent != null )
  if ( parent.getGroupId().equals( model.getGroupId() ) && 
      parent.getArtifactId().equals( model.getArtifactId() ) )
validateStringNotEmpty( "version", result, model.getVersion() );
for ( Iterator it = model.getDependencies().iterator(); it.hasNext(); )
DependencyManagement mgmt = model.getDependencyManagement();
if ( mgmt != null )
Build build = model.getBuild();
if ( build != null )

相关文章

Model类方法