本文整理汇总了Java中org.apache.maven.shared.invoker.Invoker.setMavenHome方法的典型用法代码示例。如果您正苦于以下问题:Java Invoker.setMavenHome方法的具体用法?Java Invoker.setMavenHome怎么用?Java Invoker.setMavenHome使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.shared.invoker.Invoker
的用法示例。
在下文中一共展示了Invoker.setMavenHome方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeMaven
import org.apache.maven.shared.invoker.Invoker; //导入方法依赖的package包/类
private void invokeMaven(File pomFile, String goal) throws CommandLineException, MavenInvocationException
{
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(pomFile);
request.setGoals(Collections.singletonList(goal));
request.setJavaHome(javaHome);
request.setShowErrors(true);
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(mavenHome);
InvocationResult result = invoker.execute(request);
// check status
CommandLineException executionException = result.getExecutionException();
if (executionException != null)
{
throw executionException;
}
assertEquals(0, result.getExitCode());
}
示例2: runMaven
import org.apache.maven.shared.invoker.Invoker; //导入方法依赖的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;
}
示例3: main
import org.apache.maven.shared.invoker.Invoker; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(new File("pom.xml"));
if (args.length > 0) {
if (args[0] != null && args[1] != null) {
Properties projectProperties = new Properties();
projectProperties.setProperty("deviceOS", args[0]);
projectProperties.setProperty("appPath", args[1]);
projectProperties.setProperty("osVersion", args[2]);
projectProperties.setProperty("deviceName", args[3]);
projectProperties.setProperty("udid", args[4]);
request.setProperties(projectProperties);
}
}
request.setGoals(Collections.singletonList("test"));
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File(System.getenv("M2_HOME")));
try {
invoker.execute(request);
} catch (MavenInvocationException e) {
e.printStackTrace();
}
}
示例4: execute
import org.apache.maven.shared.invoker.Invoker; //导入方法依赖的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);
}
示例5: getClassPath
import org.apache.maven.shared.invoker.Invoker; //导入方法依赖的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;
}
示例6: setupInvoker
import org.apache.maven.shared.invoker.Invoker; //导入方法依赖的package包/类
private Invoker setupInvoker() {
Invoker invoker = new DefaultInvoker();
File calculatedMavenHome = ReleaseUtil.getMavenHome(Optional.fromNullable(this.mavenHome));
if (calculatedMavenHome != null) {
this.log.debug("\tUsing maven home: " + calculatedMavenHome.getAbsolutePath());
invoker.setMavenHome(calculatedMavenHome);
}
return invoker;
}
示例7: runGoals
import org.apache.maven.shared.invoker.Invoker; //导入方法依赖的package包/类
private int runGoals(String pathToRootOfProject, String... goals) {
InvocationRequest request = new DefaultInvocationRequest();
request.setGoals(Arrays.asList(goals));
request.setPomFile(new File(pathToRootOfProject + FILE_SEPARATOR + POM_FILE));
request.setJavaHome(new File(System.getProperty("java.home")));
Properties properties = new Properties();
properties.setProperty("enforcer.skip", "true");
properties.setProperty("checkstyle.skip", "true");
properties.setProperty("cobertura.skip", "true");
properties.setProperty("skipITs", "true");
properties.setProperty("rat.skip", "true");
properties.setProperty("license.skip", "true");
properties.setProperty("findbugs.skip", "true");
properties.setProperty("gpg.skip", "true");
request.setProperties(properties);
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File(this.mavenHome));
LOGGER.info(String.format("run maven %s", Arrays.stream(goals).collect(Collectors.joining(" "))));
if (Main.verbose) {
invoker.setOutputHandler(System.out::println);
invoker.setErrorHandler(System.err::println);
} else {
invoker.setOutputHandler(null);
invoker.setErrorHandler(null);
}
try {
return invoker.execute(request).getExitCode();
} catch (MavenInvocationException e) {
throw new RuntimeException(e);
}
}