本文整理汇总了Java中org.apache.maven.model.building.DefaultModelBuildingRequest类的典型用法代码示例。如果您正苦于以下问题:Java DefaultModelBuildingRequest类的具体用法?Java DefaultModelBuildingRequest怎么用?Java DefaultModelBuildingRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultModelBuildingRequest类属于org.apache.maven.model.building包,在下文中一共展示了DefaultModelBuildingRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDependencyResolutionContext
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private void updateDependencyResolutionContext(
List<Map<String, String>> bomDependencies) {
URI[] uris = Grape.getInstance().resolve(null,
bomDependencies.toArray(new Map[bomDependencies.size()]));
DefaultModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance();
for (URI uri : uris) {
try {
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setModelResolver(new GrapeModelResolver());
request.setModelSource(new UrlModelSource(uri.toURL()));
request.setSystemProperties(System.getProperties());
Model model = modelBuilder.build(request).getEffectiveModel();
this.resolutionContext.addDependencyManagement(
new MavenModelDependencyManagement(model));
}
catch (Exception ex) {
throw new IllegalStateException("Failed to build model for '" + uri
+ "'. Is it a valid Maven bom?", ex);
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:DependencyManagementBomTransformation.java
示例2: testLocationTrackerShouldBeExcludedFromInterpolation
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
public void testLocationTrackerShouldBeExcludedFromInterpolation()
{
Properties props = new Properties();
props.setProperty( "expression", "value" );
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setUserProperties( props );
InputSource source = new InputSource();
source.setLocation( "${expression}" );
source.setModelId( "${expression}" );
Model model = new Model();
model.setLocation( "", new InputLocation( 1, 1, source ) );
SimpleProblemCollector problems = new SimpleProblemCollector();
StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator();
interpolator.interpolateObject( model, model, null, request, problems );
assertProblemFree( problems );
assertEquals( "${expression}", source.getLocation() );
assertEquals( "${expression}", source.getModelId() );
}
示例3: getModelFromFile
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
/**f
* Read the given POM so it can be used as the source of coordinates, etc.
* during artifact construction. Note that if this object's
* {@link #snapshots} property is true, and we're working with a development
* build ({@link #buildNumber} ends with 'd'), the POM is modified to remove
* the SNAPSHOT qualifier.
*
* @param pom
* the POM file containing the artifact metadata
* @return A Maven model to be used at
* {@link com.isomorphic.maven.packaging.Module#Module(Model)}
* Module construction
* @throws ModelBuildingException
* if the Model cannot be built from the given POM
* @throws IOException
* if the Model cannot be built from the given POM
*/
private Model getModelFromFile(File pom) throws ModelBuildingException, IOException {
if (buildNumber.endsWith("d") && !snapshots) {
LOGGER.info(
"Rewriting file to remove SNAPSHOT qualifier from development POM '{}'",
pom.getName());
String content = FileUtils.readFileToString(pom);
content = content.replaceAll("-SNAPSHOT", "");
FileUtils.write(pom, content);
}
ModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setPomFile(pom);
ModelBuildingResult result = modelBuilder.build(request);
return result.getEffectiveModel();
}
示例4: modelBuildingRequestTemplate
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
@Bean
public ModelBuildingRequest modelBuildingRequestTemplate(RepositorySystemSession repositorySystemSession, LocalRepositoryModelResolver localRepositoryModelResolver) {
Properties userProperties = new Properties();
userProperties.putAll(repositorySystemSession.getUserProperties());
Properties systemProperties = new Properties();
systemProperties.putAll(repositorySystemSession.getSystemProperties());
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setProcessPlugins(true);
request.setLocationTracking(true);
request.setModelResolver(localRepositoryModelResolver);
request.setUserProperties(userProperties);
request.setSystemProperties(systemProperties);
return request;
}
示例5: complexModelBuilding
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
/**
*
* TODO: This does not currently work.
*
*/
@SuppressWarnings("unused")
private static Model complexModelBuilding(File file) throws Exception {
ModelBuilder builder = new DefaultModelBuilder();
ModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setProcessPlugins(false);
request.setPomFile(file);
// request.setModelResolver(new ModelResolver() {});
request.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
//noinspection UnnecessaryLocalVariable
Model model = builder.build(request).getEffectiveModel();
return model;
}
示例6: createModelBuildingRequest
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private ModelBuildingRequest createModelBuildingRequest( File pomFile )
{
FlattenModelResolver resolver = new FlattenModelResolver( this.localRepository, this.artifactFactory,
this.dependencyResolver, this.session.getProjectBuildingRequest(), this.session.getAllProjects() );
Properties userProperties = this.session.getUserProperties();
List<String> activeProfiles = this.session.getRequest().getActiveProfiles();
// @formatter:off
ModelBuildingRequest buildingRequest =
new DefaultModelBuildingRequest().setUserProperties( userProperties ).setSystemProperties( System.getProperties() ).setPomFile( pomFile ).setModelResolver( resolver ).setActiveProfileIds( activeProfiles );
// @formatter:on
return buildingRequest;
}
示例7: testCreateEffectivePom
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
/**
* Tests method to create effective POM.
*
* @throws Exception if something goes wrong.
*/
@Test
public void testCreateEffectivePom()
throws Exception
{
String magicValue = "magic-value";
Properties userProperties = new Properties();
userProperties.setProperty( "cmd.test.property", magicValue );
File pomFile = new File( "src/test/resources/cmdpropertysubstituion/pom.xml" );
ArtifactRepository localRepository = new MavenArtifactRepository();
localRepository.setLayout( new DefaultRepositoryLayout() );
ArtifactFactory artifactFactory = new DefaultArtifactFactory();
ArtifactHandlerManager artifactHandlerManager = new DefaultArtifactHandlerManager();
setDeclaredField( artifactFactory, "artifactHandlerManager", artifactHandlerManager );
Map<String, ArtifactHandler> artifactHandlers = new HashMap<String, ArtifactHandler>();
setDeclaredField( artifactHandlerManager, "artifactHandlers", artifactHandlers );
DefaultDependencyResolver depencencyResolver = new DefaultDependencyResolver();
DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
FlattenModelResolver resolver = new FlattenModelResolver( localRepository, artifactFactory,
depencencyResolver, projectBuildingRequest, Collections.<MavenProject>emptyList() );
ModelBuildingRequest buildingRequest =
new DefaultModelBuildingRequest().setPomFile( pomFile ).setModelResolver( resolver ).setUserProperties( userProperties );
Model effectivePom = FlattenMojo.createEffectivePom( buildingRequest, false );
assertThat( effectivePom.getName() ).isEqualTo( magicValue );
}
示例8: createModel
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
public static Model createModel(File pom) throws ModelBuildingException, ComponentLookupException
{
ModelBuilder builder = mavenContainer.lookup(ModelBuilder.class);
ModelBuildingRequest req = new DefaultModelBuildingRequest();
req.setProcessPlugins(false);
req.setModelResolver(new RepoModelResolver());
req.setPomFile(pom);
return builder.build(req).getEffectiveModel();
}
示例9: loadPomFromFile
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
public Model loadPomFromFile(File pomFile, String... profiles)
{
RepositorySystem system = mavenContainer.getRepositorySystem();
Settings settings = mavenContainer.getSettings();
DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest()
.setSystemProperties(System.getProperties())
.setPomFile(pomFile)
.setActiveProfileIds(settings.getActiveProfiles());
ModelBuilder builder = new DefaultModelBuilderFactory().newInstance();
ModelBuildingResult result;
try
{
request.setModelResolver(new MavenModelResolver(system, session,
MavenRepositories.getRemoteRepositories(mavenContainer, settings)));
result = builder.build(request);
}
// wrap exception message
catch (ModelBuildingException e)
{
String pomPath = request.getPomFile().getAbsolutePath();
StringBuilder sb = new StringBuilder("Found ").append(e.getProblems().size())
.append(" problems while building POM model from ").append(pomPath).append("\n");
int counter = 1;
for (ModelProblem problem : e.getProblems())
{
sb.append(counter++).append("/ ").append(problem).append("\n");
}
throw new RuntimeException(sb.toString());
}
return result.getEffectiveModel();
}
示例10: validateEffective
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private SimpleProblemCollector validateEffective( String pom, int level )
throws Exception
{
ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( level );
SimpleProblemCollector problems = new SimpleProblemCollector();
validator.validateEffectiveModel( read( pom ), request, problems );
return problems;
}
示例11: validateRaw
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private SimpleProblemCollector validateRaw( String pom, int level )
throws Exception
{
ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( level );
SimpleProblemCollector problems = new SimpleProblemCollector();
validator.validateRawModel( read( pom ), request, problems );
return problems;
}
示例12: createModelBuildingRequest
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private ModelBuildingRequest createModelBuildingRequest( Properties p )
{
ModelBuildingRequest config = new DefaultModelBuildingRequest();
if ( p != null )
{
config.setSystemProperties( p );
}
return config;
}
示例13: testFinalFieldsExcludedFromInterpolation
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
public void testFinalFieldsExcludedFromInterpolation()
{
Properties props = new Properties();
props.setProperty( "expression", "value" );
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setUserProperties( props );
SimpleProblemCollector problems = new SimpleProblemCollector();
StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator();
interpolator.interpolateObject( new ClassWithFinalField(), new Model(), null, request, problems );
assertProblemFree( problems );
}
示例14: loadPomModel
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private Model loadPomModel(Path pomFile) {
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setPomFile(pomFile.toFile());
try {
ModelBuildingResult result = modelBuilder.build(request);
return result.getRawModel();
} catch (ModelBuildingException | IllegalArgumentException e) {
// IllegalArg can be thrown if the parent POM cannot be resolved.
throw new RuntimeException(e);
}
}
示例15: constructModel
import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private Model constructModel(File file, Model model) {
ModelBuilder modelBuilder = MODEL_BUILDER_FACTORY.newInstance();
try {
ModelBuildingRequest req = new DefaultModelBuildingRequest().setPomFile(file);
ModelBuildingResult modelBuildingResult = modelBuilder.build(req);
Model constructed = Preconditions.checkNotNull(modelBuildingResult.getRawModel());
return merge(model, constructed);
} catch (ModelBuildingException e) {
throw new RuntimeException(e);
}
}