本文整理汇总了Java中org.apache.maven.execution.MavenExecutionRequest.setPom方法的典型用法代码示例。如果您正苦于以下问题:Java MavenExecutionRequest.setPom方法的具体用法?Java MavenExecutionRequest.setPom怎么用?Java MavenExecutionRequest.setPom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.execution.MavenExecutionRequest
的用法示例。
在下文中一共展示了MavenExecutionRequest.setPom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newMavenRequest
import org.apache.maven.execution.MavenExecutionRequest; //导入方法依赖的package包/类
public MavenExecutionRequest newMavenRequest(
File pom, List<String> activeProfiles, List<String> inactiveProfiles, List<String> goals) {
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
try {
getMavenComponent(MavenExecutionRequestPopulator.class)
.populateFromSettings(request, settings);
request.setGoals(goals);
request.setPom(pom);
getMavenComponent(MavenExecutionRequestPopulator.class).populateDefaults(request);
request.setSystemProperties(properties);
request.setActiveProfiles(activeProfiles);
request.setInactiveProfiles(inactiveProfiles);
request.setStartTime(buildDate);
return request;
} catch (MavenExecutionRequestPopulationException e) {
throw new RuntimeException(e);
}
}
示例2: onEvent
import org.apache.maven.execution.MavenExecutionRequest; //导入方法依赖的package包/类
@Override
public void onEvent(Object event) throws Exception {
if (event instanceof MavenExecutionRequest) {
if (stamper.isEnabled()) {
logger.info("[FreezePomSpy]: Received a " + MavenExecutionRequest.class.getSimpleName());
MavenExecutionRequest mavenExecutionRequest = (MavenExecutionRequest)event;
File pomFile = mavenExecutionRequest.getPom();
if (!MavenConventions.FROZEN_POM_FILE.equals(pomFile.getName())) {
logger.info("[FreezeModelLocator]: Freeze pom " + pomFile.getAbsolutePath());
artifactFreezeMapping.put(pomFile);
logger.debug("[FreezeModelLocator]: Freezing pom " + pomFile.getAbsolutePath());
mavenExecutionRequest.setPom(pomFreezer.freeze(pomFile));
}
}
}
}
示例3: testArtifactFixer
import org.apache.maven.execution.MavenExecutionRequest; //导入方法依赖的package包/类
public void testArtifactFixer() throws Exception { // #197669
File main = TestFileUtils.writeFile(new File(getWorkDir(), "main/pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" +
"<parent><groupId>g</groupId><artifactId>p</artifactId><version>0</version></parent>" +
"<artifactId>m</artifactId>" +
"<dependencies><dependency><groupId>g</groupId><artifactId>s</artifactId><version>0</version></dependency></dependencies>" +
"</project>");
final File parent = TestFileUtils.writeFile(new File(getWorkDir(), "parent/pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" +
"<groupId>g</groupId><artifactId>p</artifactId><version>0</version>" +
"<packaging>pom</packaging>" +
"<properties><k>v</k></properties>" +
"</project>");
final File sibling = TestFileUtils.writeFile(new File(getWorkDir(), "sib/pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" +
"<groupId>g</groupId><artifactId>s</artifactId><version>0</version>" +
"<dependencies><dependency><groupId>g</groupId><artifactId>b</artifactId><version>0</version></dependency></dependencies>" +
"</project>");
final File binary = TestFileUtils.writeZipFile(new File(getWorkDir(), "b.jar"), "g/r:stuff");
MockLookup.setInstances(new ArtifactFixer() {
@Override public File resolve(org.eclipse.aether.artifact.Artifact artifact) {
String id = artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getExtension() + ':' + artifact.getVersion();
if (id.equals("g:p:pom:0")) {
return parent;
} else if (id.equals("g:s:pom:0")) {
return sibling;
} else if (id.equals("g:b:jar:0")) {
return binary;
} else {
return null;
}
}
});
MavenEmbedder e = EmbedderFactory.getProjectEmbedder();
MavenExecutionRequest req = e.createMavenExecutionRequest();
req.setPom(main);
req.setOffline(true);
MavenExecutionResult res = e.readProjectWithDependencies(req, true);
assertEquals(Collections.emptyList(), res.getExceptions());
MavenProject prj = res.getProject();
assertEquals("v", prj.getProperties().getProperty("k"));
assertEquals("[g:b:jar:0:compile, g:s:jar:0:compile]", new TreeSet<Artifact>(prj.getArtifacts()).toString());
}
示例4: freezePom
import org.apache.maven.execution.MavenExecutionRequest; //导入方法依赖的package包/类
private void freezePom(MavenExecutionRequest request) {
// On Jenkins a MavenExecutionRequest is not triggered
// Trigger freeze in case of Jenkins maven plugin check instance ?
if (stamper.isEnabled()) {
logger.info("[JenkinsDefaultMaven]: Freezing is enabled");
File pomFile = request.getPom();
if (!MavenConventions.FROZEN_POM_FILE.equals(pomFile.getName())) {
logger.info("[JenkinsDefaultMaven]: Freeze pom " + pomFile.getAbsolutePath());
artifactFreezeMapping.put(pomFile);
logger.debug("[JenkinsDefaultMaven]: Freezing pom " + pomFile.getAbsolutePath());
request.setPom(pomFreezer.freeze(pomFile));
}
}
}
示例5: getMavenProject
import org.apache.maven.execution.MavenExecutionRequest; //导入方法依赖的package包/类
private MavenProject getMavenProject(String pomPath) throws Exception {
File pom = new File(pomPath);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setPom(pom);
ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
return lookup( ProjectBuilder.class ).build( pom, configuration ).getProject();
}