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


Java InvocationRequest.setProperties方法代码示例

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


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

示例1: getArtifactJar

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public File getArtifactJar(String groupId, String artifactId, String version) {
    Properties properties = new Properties();
    properties.put("groupId", groupId);
    properties.put("artifactId", artifactId);
    properties.put("version", version);

    InvocationRequest request = new DefaultInvocationRequest();
    request.setLocalRepositoryDirectory(localMavenRepo);
    request.setInteractive(false);
    List<String> goalList = Arrays.asList("org.apache.maven.plugins:maven-dependency-plugin:2.10:get");
    request.setGoals(goalList);
    request.setProperties(properties);

    try {
        Invoker invoker = new DefaultInvoker();
        InvocationResult result = invoker.execute(request);
        int exitCode = result.getExitCode();
        LOG.info("maven result " + exitCode + " exception: " + result.getExecutionException());
        assertEquals("Failed to invoke maven goals: " + goalList + " with properties: " + properties + ". Exit Code: ", 0, exitCode);
    } catch (MavenInvocationException e) {
        fail("Failed to invoke maven goals: " + goalList + " with properties: " + properties + ". Exception " + e, e);
    }
    String path = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar";
    return new File(localMavenRepo, path);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:26,代码来源:ProjectGenerator.java

示例2: generate

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public String generate() throws MavenInvocationException, IOException {
    InvocationRequest request = new DefaultInvocationRequest();

    Path pomPath = Files.createTempFile("pom", ".xml");
    Files.copy(getClass().getClassLoader().getResourceAsStream(POM_PATH),
            pomPath, StandardCopyOption.REPLACE_EXISTING);

    request.setPomFile(pomPath.toFile());
    request.setProperties(config.asJaxb2Properties());
    request.setGoals(Arrays.asList("clean", "generate-sources"));

    InvocationResult result = new DefaultInvoker().execute(request);

    if(result.getExitCode() != 0) {
        LOG.info("Xmlgen failed: {}", result.getExecutionException());
    }

    pomPath.toFile().delete();

    return capitalize(sanitize(XmlPath.from(new File(config.getInputPath()))
            .getNode("schema").getNode("element").getAttribute("name"))) + "Type";
}
 
开发者ID:qameta,项目名称:rarc,代码行数:23,代码来源:XmlCodegen.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: main

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的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();
	}
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:25,代码来源:MavenRun.java

示例5: mvnCleanPackageWithProperties

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public void mvnCleanPackageWithProperties(
        final String path, final Properties properties, final File customSettingsFile) {

    final InvocationRequest request = new DefaultInvocationRequest();
    request.setProperties(properties);
    if (customSettingsFile != null && FileUtils.sizeOf(customSettingsFile) > 0) {
        request.setUserSettingsFile(customSettingsFile);
    }
    final List<String> mavenGoals = new ArrayList<>();
    mavenGoals.add("clean");
    mavenGoals.add("package");
    request.setGoals(mavenGoals);
    logToHandler(request.getGoals(), properties);
    logToFile(request.getGoals(), properties);
    invoke(request, path);
}
 
开发者ID:apache,项目名称:syncope,代码行数:17,代码来源:MavenUtils.java

示例6: invokePostArchetypeGenerationGoals

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private void invokePostArchetypeGenerationGoals(String goals, String artifactId, Properties properties)
        throws MojoExecutionException, MojoFailureException {
    getLog().info("Invoking post-archetype-generation goals: " + goals);

    File projectBasedir = new File(basedir, artifactId);

    if (projectBasedir.exists()) {
        InvocationRequest request = new DefaultInvocationRequest()
                .setBaseDirectory(projectBasedir)
                .setGoals(Arrays.asList(StringUtils.split(goals, ",")));

        if(properties != null){
            request.setProperties(properties);
        }

        try {
            invoker.execute(request);
        } catch (MavenInvocationException e) {
            throw new MojoExecutionException("Cannot run additions goals.", e);
        }
    } else {
        getLog().info("Additional goals aborted: unavailable basedir " + projectBasedir);
    }
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:25,代码来源:CreateMojo.java

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

示例8: createInvocationRequestWithGoals

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private InvocationRequest createInvocationRequestWithGoals(
    List<String> goals,
    Properties properties
) {
  final InvocationRequest invocationRequest = new DefaultInvocationRequest();
  invocationRequest.setPomFile(new File(pom));
  invocationRequest.setGoals(goals);
  invocationRequest.setProperties(properties);
  return invocationRequest;
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:11,代码来源:AllGoalsMojo.java

示例9: 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;
}
 
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:31,代码来源:BuildProject.java

示例10: 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;
}
 
开发者ID:fedora-java,项目名称:xmvn,代码行数:35,代码来源:BisectCliRequest.java

示例11: runGoals

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的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);
	}
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:34,代码来源:MavenAutomaticBuilder.java

示例12: createRequest

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private static InvocationRequest createRequest() throws IOException {
	final InvocationRequest request = new DefaultInvocationRequest();
	request.setLocalRepositoryDirectory(createDirectories(LOCAL_MAVEN_REPO).toFile());
	final Properties props = new Properties();
	props.setProperty("stacktraceEnabled", "true");
	props.setProperty("localMavenRepo", LOCAL_MAVEN_REPO.toString());
	request.setProperties(props);
	return request;
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:10,代码来源:MvnRunner.java

示例13: assertArtifactInLocalRepo

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public void assertArtifactInLocalRepo(final String groupId, final String artifactId, final String version)
		throws IOException, MavenInvocationException {
	final String artifact = groupId + ":" + artifactId + ":" + version + ":pom";
	final InvocationRequest request = createRequest();
	request.setGoals(Collections.singletonList("org.apache.maven.plugins:maven-dependency-plugin:2.10:get"));

	final Properties props = new Properties();
	props.setProperty("artifact", artifact);

	request.setProperties(props);
	final Invoker invoker = new DefaultInvoker();
	final CollectingLogOutputStream logOutput = new CollectingLogOutputStream(false);
	invoker.setOutputHandler(new PrintStreamHandler(new PrintStream(logOutput), true));
	final InvocationResult result = invoker.execute(request);

	if (result.getExitCode() != 0) {
		System.out.println();
		System.out.println(
				"There was a problem checking for the existence of the artifact. Here is the output of the mvn command:");
		System.out.println();
		for (final String line : logOutput.getLines()) {
			System.out.println(line);
		}
	}

	assertThat(format("Could not find artifact %s:%s in repository", artifact, "pom"), result.getExitCode(), is(0));
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:28,代码来源:MvnRunner.java

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

示例15: archetypeGenerate

import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public void archetypeGenerate(
        final String archetypeVersion,
        final String groupId,
        final String artifactId,
        final String secretKey,
        final String anonymousKey,
        final String jwsKey,
        final String adminPassword,
        final String installPath,
        final File customSettingsFile) {

    final InvocationRequest request = new DefaultInvocationRequest();
    request.setGoals(Collections.singletonList(
            archetypeVersion.contains("SNAPSHOT")
            ? "org.apache.maven.plugins:maven-archetype-plugin:2.4:generate"
            : "archetype:generate"));
    request.setBatchMode(true);
    final Properties properties =
            archetypeProperties(archetypeVersion, groupId, artifactId, secretKey,
                                anonymousKey, jwsKey, adminPassword);
    request.setProperties(properties);
    if (customSettingsFile != null && FileUtils.sizeOf(customSettingsFile) > 0) {
        request.setUserSettingsFile(customSettingsFile);
    }
    logToHandler(request.getGoals(), properties);
    logToFile(request.getGoals(), properties);
    invoke(request, installPath);
}
 
开发者ID:apache,项目名称:syncope,代码行数:29,代码来源:MavenUtils.java


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