本文整理汇总了Java中org.apache.maven.shared.invoker.InvocationRequest.setProfiles方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationRequest.setProfiles方法的具体用法?Java InvocationRequest.setProfiles怎么用?Java InvocationRequest.setProfiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.shared.invoker.InvocationRequest
的用法示例。
在下文中一共展示了InvocationRequest.setProfiles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: backGroundBuild
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
void backGroundBuild(MavenProject project) throws MojoExecutionException {
MavenExecutionRequest executionRequest = session.getRequest();
InvocationRequest request = new DefaultInvocationRequest();
request.setBaseDirectory(project.getBasedir());
request.setPomFile(project.getFile());
request.setGoals(executionRequest.getGoals());
request.setRecursive(false);
request.setInteractive(false);
request.setProfiles(executionRequest.getActiveProfiles());
request.setProperties(executionRequest.getUserProperties());
Invoker invoker = new DefaultInvoker();
try {
InvocationResult result = invoker.execute(request);
if (result.getExitCode() != 0) {
throw new IllegalStateException("Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]", result.getExecutionException());
}
} catch (MavenInvocationException e) {
throw new IllegalStateException("Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]", e);
}
}
示例2: setupInvocationRequest
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private InvocationRequest setupInvocationRequest() throws MojoExecutionException {
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(this.project.getFile());
// installation and deployment are performed in a later step. We first need to ensure that there are no changes in
// the scm, ...
request.setGoals(this.goals);
request.setProperties(this.releaseArgs);
request.setProfiles(this.profiles);
request.setShellEnvironmentInherited(true);
for (String key : this.releaseEnvironmentVariables.keySet()) {
request.addShellEnvironment(key, this.releaseEnvironmentVariables.get(key));
}
request.setOffline(this.settings.isOffline());
request.setInteractive(this.settings.isInteractiveMode());
MavenExecutionRequest originalRequest = this.session.getRequest();
File globalSettingsFile = originalRequest.getGlobalSettingsFile();
if (globalSettingsFile != null && globalSettingsFile.exists() && globalSettingsFile.isFile()) {
request.setGlobalSettingsFile(globalSettingsFile);
}
File userSettingsFile = originalRequest.getUserSettingsFile();
if (userSettingsFile != null && userSettingsFile.exists() && userSettingsFile.isFile()) {
request.setUserSettingsFile(userSettingsFile);
}
File toolchainsFile = originalRequest.getUserToolchainsFile();
if (toolchainsFile.exists() && toolchainsFile.isFile()) {
request.setToolchainsFile(toolchainsFile);
}
return request;
}
示例3: createInvocationRequest
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public InvocationRequest createInvocationRequest()
{
InvocationRequest request = new DefaultInvocationRequest();
request.setAlsoMake( alsoMake );
request.setAlsoMakeDependents( alsoMakeDependents );
request.setDebug( debug );
request.setFailureBehavior( failureBehavior );
request.setGlobalChecksumPolicy( globalChecksumPolicy );
request.setGlobalSettingsFile( stringToFile( globalSettings ) );
request.setGoals( goals );
request.setInteractive( !batchMode );
request.setJavaHome( stringToFile( javaHome ) );
request.setLocalRepositoryDirectory( stringToFile( localRepository ) );
request.setMavenOpts( mavenOpts );
request.setOffline( offline );
request.setPomFile( stringToFile( pomFile ) );
request.setProfiles( profiles );
request.setProjects( projects );
request.setRecursive( !nonRecursive );
request.setResumeFrom( resumeFrom );
request.setShowErrors( showErrors );
request.setShowVersion( showVersion );
request.setThreads( threads );
request.setToolchainsFile( stringToFile( toolchains ) );
request.setUpdateSnapshots( updateSnapshots );
request.setUserSettingsFile( stringToFile( userSettings ) );
Properties properties = new Properties();
defines.forEach( ( key, value ) -> properties.put( key, value ) );
request.setProperties( properties );
return request;
}
示例4: generateTempJar
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private void generateTempJar(String subDirName) {
// generate sahagin temp jar for test from the already generated class files
InvocationRequest jarGenRequest = new DefaultInvocationRequest();
if (System.getProperty("sahagin.maven.java.home") != null) {
jarGenRequest.setJavaHome(new File(System.getProperty("sahagin.maven.java.home")));
}
jarGenRequest.setProfiles(Arrays.asList("sahagin-temp-jar-gen"));
jarGenRequest.setGoals(Arrays.asList("jar:jar"));
MavenInvokeResult jarGenResult = mavenInvoke(jarGenRequest, subDirName + ":jarGen");
if (!jarGenResult.succeeded) {
jarGenResult.printStdOutsAndErrs();
fail("fail to generate jar");
}
}
示例5: invokeChildTest
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private Pair<MavenInvokeResult, JavaConfig> invokeChildTest(
String subDirName, String additionalProfile) throws IOException {
// set up working directory
clearWorkDir(subDirName);
File workDir = mkWorkDir(subDirName).getAbsoluteFile();
JavaConfig conf = new JavaConfig(workDir);
conf.setTestDir(new File(workDir, "src/test/java"));
conf.setRunTestOnly(true);
YamlUtils.dump(conf.toYamlObject(), new File(workDir, "sahagin.yml"));
FileUtils.copyFile(new File("pom.xml"), new File(workDir, "pom.xml"));
FileUtils.copyDirectory(testResourceDir(subDirName + "/src"), new File(workDir, "src"));
FileUtils.copyDirectory(testResourceDir("expected/captures"), new File(workDir, "captures"));
// execute test
InvocationRequest testRequest = new DefaultInvocationRequest();
if (System.getProperty("sahagin.maven.java.home") != null) {
testRequest.setJavaHome(new File(System.getProperty("sahagin.maven.java.home")));
}
testRequest.setGoals(Arrays.asList("clean", "test"));
if (additionalProfile == null) {
testRequest.setProfiles(Arrays.asList("sahagin-jar-test"));
} else {
testRequest.setProfiles(Arrays.asList("sahagin-jar-test", additionalProfile));
}
String jarPathOpt = "-Dsahagin.temp.jar="
+ new File("target/sahagin-temp.jar").getAbsolutePath();
testRequest.setMavenOpts(jarPathOpt);
testRequest.setBaseDirectory(workDir);
MavenInvokeResult testResult = mavenInvoke(testRequest, subDirName + ":test");
return Pair.of(testResult, conf);
}
示例6: createAndConfigureAnInvocationRequest
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
protected InvocationRequest createAndConfigureAnInvocationRequest( ItemWithProperties currentValue )
{
InvocationRequest request = new DefaultInvocationRequest();
request.setAlsoMake( isAlsoMake() );
request.setAlsoMakeDependents( isAlsoMakeDependents() );
request.setDebug( isDebug() );
request.setFailureBehavior( getFailureBehaviour() );
request.setGlobalChecksumPolicy( getGlobalChecksumPolicy() );
request.setGlobalSettingsFile( getGlobalSettingsFile() );
request.setInteractive( isInteractive() );
request.setLocalRepositoryDirectory( getLocalRepositoryDirectory() );
request.setMavenOpts( getMavenOpts() );
request.setNonPluginUpdates( isNonPluginUpdates() );
request.setOffline( isOffline() );
// request.setProperties( properties )
// ;
// @TODO: Think about it.
// request.setPomFile(pomFile);
// @TODO: Think about it.
// request.setPomFileName(pomFilename);
// The following parameter do make sense to use a placeholder
// base directory
// cd @[email protected]
// mvn clean package
request.setBaseDirectory( getBaseDirectoryAfterPlaceHolderIsReplaced( currentValue.getName() ) );
// goals:
// mvn plugin-name:@[email protected]
//
request.setGoals( getGoalsAfterPlaceHolderIsReplaced( currentValue.getName() ) );
// Profiles:
// mvn [email protected][email protected] clean package
// mvn [email protected]@
request.setProfiles( getProfilesAfterPlaceHolderIsReplaced( currentValue.getName() ) );
// Projects:
// mvn -pl [email protected]@ clean package
request.setProjects( getProjectsAfterPlaceHolderIsReplaced( currentValue.getName() ) );
Properties props = getMergedProperties(currentValue );
request.setProperties( props );
request.setRecursive( isRecursive() );
request.setResumeFrom( getResumeFrom() );
request.setShellEnvironmentInherited( isShellEnvironmentInherited() );
request.setShowErrors( isShowErrors() );
request.setShowVersion( isShowVersion() );
request.setThreads( getThreads() );
request.setToolchainsFile( getToolchains() );
request.setUpdateSnapshots( isUpdateSnapshots() );
request.setUserSettingsFile( getUserSettings() );
return request;
}