当前位置: 首页>>代码示例>>Java>>正文


Java InvocationRequest.setBaseDirectory方法代码示例

本文整理汇总了Java中org.apache.maven.shared.invoker.InvocationRequest.setBaseDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationRequest.setBaseDirectory方法的具体用法?Java InvocationRequest.setBaseDirectory怎么用?Java InvocationRequest.setBaseDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.shared.invoker.InvocationRequest的用法示例。


在下文中一共展示了InvocationRequest.setBaseDirectory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runMaven

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public List<String> runMaven(final File workingDir, final String... arguments) throws IOException {
	final InvocationRequest request = createRequest();

	request.setGoals(asList(arguments));
	request.setBaseDirectory(workingDir);

	final Invoker invoker = new DefaultInvoker();
	invoker.setMavenHome(mvnHome);
	final CollectingLogOutputStream logOutput = new CollectingLogOutputStream(false);
	invoker.setOutputHandler(new PrintStreamHandler(new PrintStream(logOutput), true));

	int exitCode;
	try {
		final InvocationResult result = invoker.execute(request);
		exitCode = result.getExitCode();
	} catch (final Exception e) {
		throw new MavenExecutionException(1, logOutput.getLines());
	}
	final List<String> output = logOutput.getLines();

	if (exitCode != 0) {
		throw new MavenExecutionException(exitCode, output);
	}

	return output;
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:27,代码来源:MvnRunner.java

示例2: executeLicenseProject

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private void executeLicenseProject(File pomFile, File repoDir) throws Exception {
    InvocationRequest mavenRequest = new DefaultInvocationRequest();
    mavenRequest.setPomFile(pomFile);
    mavenRequest.setBaseDirectory(pomFile.getParentFile());
    mavenRequest.setUserSettingsFile(userSettings);
    mavenRequest.setLocalRepositoryDirectory(repoDir);
    mavenRequest.setGoals(Arrays.asList("clean", "package"));

    Invoker invoker = new DefaultInvoker();
    try {
        InvocationResult result = invoker.execute(mavenRequest);
        if (result.getExitCode() != 0) {
            throw result.getExecutionException() != null ? result.getExecutionException()
                    : new IllegalStateException("Build failure: " + result.getExitCode());
        }
        getLog().info("Licenses POM executed: " + pomFile.getAbsolutePath());
    } catch (Exception e) {
        getLog().error("Error when executing " + pomFile.getAbsolutePath(), e);
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:21,代码来源:LicenseMojo.java

示例3: 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);
    }
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:23,代码来源:AbstractSundrioMojo.java

示例4: execute

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public static void execute(File dir, List<String> commands, Properties props, boolean logToStdOut) throws MavenInvocationException {
	InvocationRequest request = new DefaultInvocationRequest();
	request.setBaseDirectory(dir);
	request.setGoals(commands);
	if (props!=null) {
		request.setProperties(props);
	}
	Invoker invoker = new DefaultInvoker();
	invoker.setMavenHome(mavenHome);
	
	if (!logToStdOut) {
		request.setOutputHandler(emptyHandler);
	}
	
	invoker.execute(request);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:MavenUtil.java

示例5: getClassPath

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public static String getClassPath(File projectDir) {
	
	InvocationRequest request = new DefaultInvocationRequest();
	request.setBaseDirectory(projectDir);
	request.setGoals(Collections.singletonList("dependency:build-classpath"));
	Invoker invoker = new DefaultInvoker();
	invoker.setMavenHome(mavenHome);

	ClassPathListener cpl = new ClassPathListener();
	invoker.setOutputHandler(cpl);

	try {
		invoker.execute(request);
	} catch (MavenInvocationException e) {
		e.printStackTrace();
	}

	return cpl.classPath;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:20,代码来源:MavenUtil.java

示例6: executeGeneratedProjectBuild

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private void executeGeneratedProjectBuild(File pomFile, File projectDir, File repoDir) throws Exception {
    InvocationRequest mavenRequest = new DefaultInvocationRequest();
    mavenRequest.setPomFile(pomFile);
    mavenRequest.setBaseDirectory(projectDir);
    mavenRequest.setUserSettingsFile(userSettings);
    mavenRequest.setLocalRepositoryDirectory(repoDir);
    mavenRequest.setGoals(Collections.singletonList("install"));

    Properties props = System.getProperties();

    if (Boolean.parseBoolean(downloadSources)) {
        props.setProperty("swarm.download.sources", "");
    }

    if (Boolean.parseBoolean(downloadPoms)) {
        props.setProperty("swarm.download.poms", "");
    }

    mavenRequest.setProperties(props);

    Invoker invoker = new DefaultInvoker();
    InvocationResult result = invoker.execute(mavenRequest);

    if (result.getExitCode() != 0) {
        throw result.getExecutionException();
    }

    getLog().info("Built project from BOM: " + projectDir.getAbsolutePath());
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:30,代码来源:RepositoryBuilderMojo.java

示例7: 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);
}
 
开发者ID:SahaginOrg,项目名称:sahagin-java,代码行数:33,代码来源:HookMethodDefTest.java

示例8: 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]@ 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;
    }
 
开发者ID:khmarbaise,项目名称:iterator-maven-plugin,代码行数:57,代码来源:AbstractInvokerMojo.java


注:本文中的org.apache.maven.shared.invoker.InvocationRequest.setBaseDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。