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


Java MavenCli类代码示例

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


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

示例1: defineIDE

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
private static void defineIDE(final String netbeansInstallation) throws IOException {
    FileObject settingsXml = FileUtil.toFileObject(MavenCli.DEFAULT_USER_SETTINGS_FILE);
    if (settingsXml == null) {
        settingsXml = FileUtil.copyFile(FileUtil.getConfigFile("Maven2Templates/settings.xml"), FileUtil.createFolder(MavenCli.DEFAULT_USER_SETTINGS_FILE.getParentFile()), "settings");
    }
    Utilities.performSettingsModelOperations(settingsXml, Collections.<ModelOperation<SettingsModel>>singletonList(new ModelOperation<SettingsModel>() {
        public @Override void performOperation(SettingsModel model) {
            Profile netbeansIde = model.getSettings().findProfileById("netbeans-ide");
            if (netbeansIde != null) {
                return;
            }
            netbeansIde = model.getFactory().createProfile();
            netbeansIde.setId("netbeans-ide");
            Activation activation = model.getFactory().createActivation();
            // XXX why does the model not have this property??
            QName ACTIVE_BY_DEFAULT = SettingsQName.createQName("activeByDefault", model.getSettingsQNames().getNamespaceVersion());
            activation.setChildElementText("activeByDefault", "true", ACTIVE_BY_DEFAULT);
            netbeansIde.setActivation(activation);
            org.netbeans.modules.maven.model.settings.Properties properties = model.getFactory().createProperties();
            properties.setProperty("netbeans.installation", netbeansInstallation);
            netbeansIde.setProperties(properties);
            model.getSettings().addProfile(netbeansIde);
        }
    }));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:RunIDEInstallationChecker.java

示例2: 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

示例3: 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

示例4: 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

示例5: removeNotify

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
@Override protected void removeNotify() {
    RepositoryPreferences.getInstance().removeChangeListener(this);
    removeChangeListener(this);
    if (addNotifyCalled) { //#213038
        try {
            FileUtil.removeFileChangeListener(this, MavenCli.DEFAULT_USER_SETTINGS_FILE);
        } catch (IllegalArgumentException exc) {
            //we just ignore, who cares
        }
        addNotifyCalled = false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:M2RepositoryBrowser.java

示例6: checkRunConfig

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
@Messages({
    "RunIDEInstallationChecker_title=Define netbeans.installation",
    "# {0} - NetBeans installation directory", "# {1} - settings.xml location", "RunIDEInstallationChecker_message="
        + "Running standalone modules or suites requires $'{'netbeans.installation} to be defined. "
        + "(Using the NetBeans Application project template avoids the need for this configuration.) "
        + "Define as {0} in {1} now?"
})
@Override public boolean checkRunConfig(RunConfig config) {
    if (config.getGoals().contains("nbm:run-ide")) {
        Project project = config.getProject();
        if (project != null) {
            NbMavenProject nbmp = project.getLookup().lookup(NbMavenProject.class);
            if (nbmp != null && MavenNbModuleImpl.findIDEInstallation(project) == null) {
                    String netbeansInstallation = new File(System.getProperty("netbeans.home")).getParent();
                    if (DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(RunIDEInstallationChecker_message(netbeansInstallation, MavenCli.DEFAULT_USER_SETTINGS_FILE), RunIDEInstallationChecker_title(), NotifyDescriptor.OK_CANCEL_OPTION)) == NotifyDescriptor.OK_OPTION) {
                        try {
                            defineIDE(netbeansInstallation);
                        } catch (IOException x) {
                            Exceptions.printStackTrace(x);
                        }
                    }
                    // config.setProperty(MavenNbModuleImpl.PROP_NETBEANS_INSTALL, netbeansInstallation);
                    return false;
            }
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:RunIDEInstallationChecker.java

示例7: getActions

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
@Override
public Action[] getActions(boolean context) {
    Collection<Action> col = new ArrayList<Action>();
    if (!MavenCli.DEFAULT_USER_SETTINGS_FILE.exists()) {
        col.add(new AddSettingsXmlAction());
    }
    return col.toArray(new Action[col.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ProjectFilesNode.java

示例8: createKeys

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
@Override protected boolean createKeys(List<FileObject> keys) {
    FileObject d = project.getProjectDirectory();
    keys.add(d.getFileObject("pom.xml")); // NOI18N
    keys.add(d.getFileObject(M2Configuration.FILENAME));
    for (FileObject kid : d.getChildren()) {
        String n = kid.getNameExt();
        if (n.startsWith(M2Configuration.FILENAME_PREFIX) && n.endsWith(M2Configuration.FILENAME_SUFFIX)) {
            keys.add(kid);
        }
    }
    keys.add(d.getFileObject(M2AuxilaryConfigImpl.CONFIG_FILE_NAME));
    keys.add(FileUtil.toFileObject(MavenCli.DEFAULT_USER_SETTINGS_FILE));
    keys.removeAll(Collections.singleton(null));
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ProjectFilesNode.java

示例9: createMavenExecutionRequest

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
/**
 * a prepopulate maven execution request object, most notably but systemProperties and userProperties 
 * fields are prepopulated with default values, typically one should only add to these values, not replace them.
 * @return 
 */
public MavenExecutionRequest createMavenExecutionRequest(){
    MavenExecutionRequest req = new DefaultMavenExecutionRequest();

    ArtifactRepository localRepository = getLocalRepository();
    req.setLocalRepository(localRepository);
    req.setLocalRepositoryPath(localRepository.getBasedir());

    //TODO: do we need to validate settings files?
    File settingsXml = embedderConfiguration.getSettingsXml();
    if (settingsXml !=null && settingsXml.exists()) {
        req.setGlobalSettingsFile(settingsXml);
    }
    if (MavenCli.DEFAULT_USER_SETTINGS_FILE != null && MavenCli.DEFAULT_USER_SETTINGS_FILE.exists()) {
      req.setUserSettingsFile(MavenCli.DEFAULT_USER_SETTINGS_FILE);
    }
    
    req.setSystemProperties(getSystemProperties());
    req.setUserProperties(embedderConfiguration.getUserProperties());
    try {
        //#212214 populating from settings needs to come first
        //it adds mirrors and proxies to the request
        //later on populateDefaults() will use these to replace/configure the default "central" repository
        // and the repository id used is important down the road for resolution in EnhancedLocalRepositoryManager
        populator.populateFromSettings(req, getSettings());
        populator.populateDefaults(req);
    } catch (MavenExecutionRequestPopulationException x) {
        // XXX where to display this?
        Exceptions.printStackTrace(x);
    }
    req.setOffline(isOffline());
    req.setRepositoryCache(new NbRepositoryCache());

    return req;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:MavenEmbedder.java

示例10: 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

示例11: 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

示例12: 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

示例13: addNotify

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
@Override protected void addNotify() {
    RepositoryPreferences.getInstance().addChangeListener(this);
    FileUtil.addFileChangeListener(this, MavenCli.DEFAULT_USER_SETTINGS_FILE);
    addChangeListener(this);
    addNotifyCalled = true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:M2RepositoryBrowser.java

示例14: NanoMavenCli

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
public NanoMavenCli(NanoMaven nanoMaven) {
    this.nanoMaven = nanoMaven;
    this.cli = new MavenCli();
    this.out = new PrintStream(new ByteArrayOutputStream());
    this.err = new PrintStream(new ByteArrayOutputStream());
}
 
开发者ID:dzikoysk,项目名称:NanoMaven,代码行数:7,代码来源:NanoMavenCli.java

示例15: CliInvoker

import org.apache.maven.cli.MavenCli; //导入依赖的package包/类
public CliInvoker(String projectDir) {
    this.projectDir = projectDir;
    this.cli = new MavenCli();

    System.setProperty("maven.multiModuleProjectDirectory", "$M2_HOME");
}
 
开发者ID:manat,项目名称:subrelease-maven-plugin,代码行数:7,代码来源:CliInvoker.java


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