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


Java MavenCli.doMain方法代码示例

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


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

示例1: execute

import org.apache.maven.cli.MavenCli; //导入方法依赖的package包/类
@Override
public void execute(final String[] arguments, final File directory) {
    LOGGER.info(String.format("Execute maven at '%s': %s", directory, Arrays.toString(arguments)));
    System.setProperty("maven.multiModuleProjectDirectory", directory.getAbsolutePath());
    final MavenCli mavenCli = new MavenCli();
    final ByteArrayOutputStream stdOutStream = new ByteArrayOutputStream();
    final ByteArrayOutputStream stdErrStream = new ByteArrayOutputStream();
    final int exitCode = mavenCli.doMain(arguments, directory.getAbsolutePath(), printStream(stdOutStream),
            printStream(stdErrStream));
    final List<String> executionOutput = toString(stdOutStream);
    if (LOGGER.isDebugEnabled() && !executionOutput.isEmpty()) {
        executionOutput.forEach(LOGGER::debug);
    }
    if (exitCode != 0) {
        throw new MavenExecutionException();
    }
}
 
开发者ID:AGETO,项目名称:hybris-maven-plugin,代码行数:18,代码来源:EmbeddedMavenExecutor.java

示例2: getTacocoClasspath

import org.apache.maven.cli.MavenCli; //导入方法依赖的package包/类
private String getTacocoClasspath() throws Exception {
	final String tacocoCpPath = 
			new PathBuilder().path(tacocoHome, "cp.txt").buildFilePath();
	if(!new File(tacocoCpPath).exists()) {
		MavenCli mavenCli = new MavenCli();
		mavenCli.doMain(
				new String[] {"dependency:build-classpath", "-Dmdep.outputFile=cp.txt"}, 
				tacocoHome,
				System.out, 
				System.out);
	}

	final String cpDependencies = new String(Files.readAllBytes(Paths.get(tacocoHome+ File.separator +"cp.txt")));
	final String tacocoTargetPath = 
			new PathBuilder()
			.path(tacocoHome, "target", "classes")
			.buildFilePath();

	String tacocoClasspath = 
			new PathBuilder()
			.path(cpDependencies, tacocoTargetPath)
			.buildClassPath();
	return tacocoClasspath;
}
 
开发者ID:spideruci,项目名称:tacoco,代码行数:25,代码来源:Launcher.java

示例3: copyDependencies

import org.apache.maven.cli.MavenCli; //导入方法依赖的package包/类
private void copyDependencies(String webappName, Model model) throws IOException {
    final Path lib = webappPaths.get(webappName).resolve("WEB-INF/lib");
    lib.toFile().mkdirs();
    File[] libs = lib.toFile().listFiles();
    if (libs != null) {
        for (File libFile : libs) {
            libFile.delete();
        }
    }

    logger.info("Copying maven dependencies of " + webappName + ". This may take some time, as some dependencies may have to be downloaded from a remote repository.");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(baos);
    MavenCli cli = new MavenCli();
    cli.doMain(new String[] {"dependency:copy-dependencies", "-DoutputDirectory=" + lib.toString()}, projectPaths.get(webappName).toString(), out, out);
    out.close();
    String output = baos.toString("UTF-8");
    if (output.contains("FAILURE")) {
        logger.warn("Problem with copying dependencies of " + webappName + ": " + output);
    }
    logger.info("Copying dependencies of " + webappName + " successful");
    writeDependencyCopyNeeded(webappName);
}
 
开发者ID:Glamdring,项目名称:aardWARk,代码行数:25,代码来源:StartupListener.java

示例4: getClasspath

import org.apache.maven.cli.MavenCli; //导入方法依赖的package包/类
@Override
public String getClasspath(){
	try{
		if(this.classpath != null) return this.classpath;
		final String tacocoCpPath = 
				new PathBuilder().path(this.targetDir).path("tacoco.cp").buildFilePath();

		if(!new File(tacocoCpPath).exists()) {
			System.setProperty("maven.multiModuleProjectDirectory", this.targetDir);
			MavenCli mavenCli = new MavenCli();
			mavenCli.doMain(new String[]{"dependency:build-classpath", "-Dmdep.outputFile=tacoco.cp"}, this.targetDir,
					System.out, System.out);
		}

		final String tacocoDependencies = new String(Files.readAllBytes(Paths.get(this.targetDir, "tacoco.cp")));
		final String targetPath = getClassDir();
		final String targetTestPath = getTestclassDir();

		classpath = new PathBuilder().path(tacocoDependencies)
				.path(targetPath)
				.path(targetTestPath)
				.buildClassPath();

	}catch(Exception e){
		e.printStackTrace();
	}
	return classpath;
}
 
开发者ID:spideruci,项目名称:tacoco,代码行数:29,代码来源:MavenModule.java

示例5: build

import org.apache.maven.cli.MavenCli; //导入方法依赖的package包/类
/**
 * Executes a specific MAVEN build specification.
 * 
 * @param root the root-path
 * @param buildFilePath the path where the MAVEN file is located
 * @param updateSnapshots whether snapshots shall be updated (-U)
 * @param targets the targets to be executed
 * @return the created artifacts
 * @throws VilException in case of artifact / parameter problems
 */
private static Set<FileArtifact> build(Path root, String buildFilePath, boolean updateSnapshots, String[] targets) 
    throws VilException {
    File targetPath = determineTargetPath(root);
    if (null != buildFilePath) {
        buildFilePath = new File(targetPath, buildFilePath).toString();
    } else {
        buildFilePath = targetPath.toString();
    }
    long timestamp = PathUtils.normalizedTime();
    int cliResult;
    if (AS_PROCESS) {
        try {
            cliResult = runAsProcess(buildFilePath, updateSnapshots, targets);
        } catch (IOException | InterruptedException e) {
            throw new VilException("maven build failed: " + e.getMessage(), 
                VilException.ID_RUNTIME_EXECUTION);
        }
    } else {
        MavenCli cli = new MavenCli();
        List<String> arguments = new ArrayList<String>();
        if (updateSnapshots) {
            arguments.add("-U");
        }
        for (String t: targets) {
            arguments.add(t);
        }
        String[] args = new String[arguments.size()];
        cliResult = cli.doMain(arguments.toArray(args), buildFilePath, System.out, System.out);
    }
    if (0 != cliResult) {
        throw new VilException("maven build failed", VilException.ID_RUNTIME_EXECUTION);
    }
    List<FileArtifact> result = new ArrayList<FileArtifact>();
    ScanResult<FileArtifact> scanResult = new ScanResult<FileArtifact>(result);
    FileUtils.scan(targetPath.getAbsoluteFile(), root.getArtifactModel(), timestamp, scanResult, 
        FileArtifact.class);
    scanResult.checkForException();
    return new ListSet<FileArtifact>(result, FileArtifact.class);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:50,代码来源:Maven.java

示例6: execute

import org.apache.maven.cli.MavenCli; //导入方法依赖的package包/类
protected String execute(String dir, String... args) throws IOException, InterruptedException {
    OutputStream outos = null;
    PrintStream outps = null;
    OutputStream erros = null;
    PrintStream errps = null;
    try {
        outos = new ByteArrayOutputStream();
        outps = new PrintStream(outos);
        erros = new ByteArrayOutputStream();
        errps = new PrintStream(erros);
        MavenCli cli = new MavenCli();
        int code = cli.doMain(args, dir, outps, errps);
        String out = outos.toString();
        String err = erros.toString();

        System.out.println("TEST MAVEN EXECUTION START >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        System.out.print("Executing: mvn");
        for (String arg : args) {
            System.out.print(' ');
            System.out.print(arg);
        }
        System.out.println();
        System.out.print("Exit code: ");
        System.out.println(code);
        System.out.print(out);
        System.err.print(err);
        System.out.println("TEST MAVEN EXECUTION END <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");

        return out + err;
    } finally {
        closeQuietly(errps);
        closeQuietly(erros);
        closeQuietly(outps);
        closeQuietly(outos);
    }
}
 
开发者ID:javalite,项目名称:activejdbc,代码行数:37,代码来源:AbstractIntegrationSpec.java


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