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


Java DefaultMavenExecutionRequest类代码示例

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


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

示例1: newMavenRequest

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
public MavenExecutionRequest newMavenRequest(
    File pom, List<String> activeProfiles, List<String> inactiveProfiles, List<String> goals) {
  MavenExecutionRequest request = new DefaultMavenExecutionRequest();
  try {
    getMavenComponent(MavenExecutionRequestPopulator.class)
        .populateFromSettings(request, settings);
    request.setGoals(goals);
    request.setPom(pom);
    getMavenComponent(MavenExecutionRequestPopulator.class).populateDefaults(request);
    request.setSystemProperties(properties);
    request.setActiveProfiles(activeProfiles);
    request.setInactiveProfiles(inactiveProfiles);
    request.setStartTime(buildDate);
    return request;

  } catch (MavenExecutionRequestPopulationException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:MavenServerImpl.java

示例2: createUpdateSession

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
private ManipulationSession createUpdateSession() throws Exception
{
    ManipulationSession session = new ManipulationSession();

    session.setState( new DependencyState( p ) );
    session.setState( new VersioningState( p ) );
    session.setState( new CommonState( p ) );

    final MavenExecutionRequest req =
                    new DefaultMavenExecutionRequest().setUserProperties( p ).setRemoteRepositories( Collections.<ArtifactRepository>emptyList() );

    final PlexusContainer container = new DefaultPlexusContainer();
    final MavenSession mavenSession = new MavenSession( container, null, req, new DefaultMavenExecutionResult() );

    session.setMavenSession( mavenSession );

    return session;
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:19,代码来源:PropertiesUtilsTest.java

示例3: lookupConfiguredMojo

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
/**
 * Workaround for parent class lookupMojo and lookupConfiguredMojo.
 * @param name the name of the Mojo to lookup
 * @param pomPath where to find the POM file
 * @return a configured MSBuild Mojo for testing
 * @throws Exception if we can't find the Mojo or the POM is malformed
 */
protected final Mojo lookupConfiguredMojo( String name, String pomPath ) throws Exception
{
    File pom = new File( getClass().getResource( pomPath ).getPath() );
    assertTrue( pom.exists() );

    // The following 4 lines are simply to get a MavenProject object
    MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
    ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
    ProjectBuilder projectBuilder = this.lookup( ProjectBuilder.class );
    MavenProject mavenProject = projectBuilder.build( pom, buildingRequest ).getProject();
    assertNotNull( mavenProject );
    
    // Used lookupMojo as it sets up most of what we need and reads configuration
    // variables from the poms.
    // It doesn't set a MavenProject so we have to do that manually
    // lookupConfiguredMojo doesn't work properly, configuration variables are no expanded
    // as we expect and it fails to setup a Log.
    Mojo mojo = lookupMojo( name, pom );
    //Mojo mojo = super.lookupConfiguredMojo( mavenProject, name );
    assertNotNull( mojo );

    setVariableValueToObject( mojo, "mavenProject", mavenProject );
    
    return mojo;
}
 
开发者ID:andi12,项目名称:msbuild-maven-plugin,代码行数:33,代码来源:AbstractMSBuildMojoTestCase.java

示例4: newSession

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
private MavenSession newSession(MavenProject project, File localrepo, Properties properties) throws Exception {
  MavenExecutionRequest request = new DefaultMavenExecutionRequest();
  MavenExecutionResult result = new DefaultMavenExecutionResult();
  DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
  LocalRepository localRepo = new LocalRepository(localrepo);
  repoSession.setLocalRepositoryManager(mojos.getContainer().lookup(LocalRepositoryManagerFactory.class, "simple").newInstance(repoSession, localRepo));
  MavenSession session = new MavenSession(mojos.getContainer(), repoSession, request, result);
  List<MavenProject> projects = new ArrayList<>();
  projects.add(project);
  for (String module : project.getModules()) {
    MavenProject moduleProject = readMavenProject(new File(project.getBasedir(), module), properties);
    moduleProject.setParent(project);
    projects.add(moduleProject);
  }

  session.setProjects(projects);
  return session;
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:19,代码来源:InstallDeployTest.java

示例5: setUp

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
@Override
protected void setUp()
    throws Exception
{
    super.setUp();
    artifactFactory = lookup( ArtifactFactory.class);        
    artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class );

    RepositorySystemSession repoSession = initRepoSession();
    MavenSession session =
        new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(),
                          new DefaultMavenExecutionResult() );

    LegacySupport legacySupport = lookup(LegacySupport.class);
    legacySupport.setSession( session );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:AbstractArtifactComponentTestCase.java

示例6: onEvent

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
@Override
public void onEvent(Object event) throws Exception {
    super.onEvent(event);
    if (configuration.isProfiling()) {
        if (event instanceof DefaultMavenExecutionRequest) {
            DefaultMavenExecutionRequest mavenEvent = (DefaultMavenExecutionRequest) event;
            statistics.setGoals(new LinkedHashSet<String>(mavenEvent.getGoals()));
            statistics.setProperties(mavenEvent.getUserProperties());
        } else if (event instanceof ExecutionEvent) {
            storeExecutionEvent((ExecutionEvent) event);
            trySaveTopProject((ExecutionEvent) event);
            storeStartTime((ExecutionEvent) event);
        } else if (event instanceof RepositoryEvent) {
            storeDownloadingArtifacts((RepositoryEvent) event);
        }
    }
}
 
开发者ID:jcgay,项目名称:maven-profiler,代码行数:18,代码来源:ProfilerEventSpy.java

示例7: testSomething

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
/**
 * @throws Exception if any
 */
@Test
public void testSomething()
        throws Exception {
    File projectBase = getTestFile("src/test/resources/com/vityuk/ginger/maven/");
    File pom = new File(projectBase, "pom.xml");
    assertNotNull(pom);
    assertTrue(pom.exists());

    MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
    ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
    ProjectBuilder projectBuilder = lookup(ProjectBuilder.class);
    MavenProject project = projectBuilder.build(pom, buildingRequest).getProject();

    MavenGeneratorMojo myMojo = (MavenGeneratorMojo) lookupConfiguredMojo(project, "ginger-generator");
    assertNotNull(myMojo);

    myMojo.execute();

    File outputDirectory = new File(myMojo.outputDirectory);
    File resultFile = new File(outputDirectory, "com/vityuk/ginger/test1/GeneralConstants.java");
    assertTrue("GeneralConstants.java is NOT generated", resultFile.exists());
}
 
开发者ID:avityuk,项目名称:ginger,代码行数:26,代码来源:MavenGeneratorTest.java

示例8: createMavenExecutionRequest

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的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

示例9: findMojo

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
private <T extends AbstractGolangMojo> T findMojo(final Class<T> klazz, final String pomName, final String goal) throws Exception {
  final File pomFile = new File(GolangMojoCfgTest.class.getResource(pomName).toURI());
  final MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
  final ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
  final ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class);
  final MavenProject project = projectBuilder.build(pomFile, buildingRequest).getProject();
  return klazz.cast(this.lookupConfiguredMojo(project, goal));
}
 
开发者ID:raydac,项目名称:mvn-golang,代码行数:9,代码来源:GolangMojoCfgTest.java

示例10: lookupMojo

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
protected Mojo lookupMojo(Path pomPath, String goal) throws Exception {
    File pom = getTestFile(pomPath.toString());
    assertTrue(pom.exists());

    MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
    ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
    buildingRequest.setRepositorySession(new DefaultRepositorySystemSession());

    ProjectBuilder projectBuilder = lookup(ProjectBuilder.class);
    MavenProject project = projectBuilder.build(pom, buildingRequest).getProject();

    return lookupConfiguredMojo(project, goal);
}
 
开发者ID:dglecom,项目名称:rpm-systemd-maven-plugin,代码行数:14,代码来源:AbstractHarnessMojoTestCase.java

示例11: lookupConfiguredMojo

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
private Mojo lookupConfiguredMojo(String goal, File pom) throws Exception
{
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setBaseDirectory(pom.getParentFile());
    ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
    // Fix for bug: https://git-wip-us.apache.org/repos/asf?p=maven-plugin-testing.git;a=commit;h=3cd5f47c586499e438a3f9393304ac9d1f9a7f53
    configuration.setRepositorySession(new DefaultRepositorySystemSession());
    MavenProject project = lookup(ProjectBuilder.class).build(pom, configuration).getProject();
    return super.lookupConfiguredMojo(project, goal);
}
 
开发者ID:NordeaOSS,项目名称:copybook4java,代码行数:11,代码来源:CodeGenMojoTest.java

示例12: testMavenExecutionRequest

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
@Test
public void testMavenExecutionRequest() throws Exception {
    DefaultMavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setPom(new File("path/to/pom.xml"));
    request.setGoals(Arrays.asList("clean", "source:jar", "deploy"));

    spy.onEvent(request);

    String actual = writer.toString();
    System.out.println(actual);
    Assert.assertThat(actual, CoreMatchers.containsString("MavenExecutionRequest"));
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:13,代码来源:JenkinsMavenEventSpyTest.java

示例13: when_disabled_maven_event_spy_must_not_call_reporter

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
@Test
public void when_disabled_maven_event_spy_must_not_call_reporter() throws Exception {
    MavenEventReporter reporterMustNeverBeInvoked = new MavenEventReporter() {
        @Override
        public void print(Object message) {
            throw new IllegalStateException();
        }

        @Override
        public void print(Xpp3Dom element) {
            throw new IllegalStateException();
        }

        @Override
        public void close() {
            throw new IllegalStateException();
        }
    };
    JenkinsMavenEventSpy spy = new JenkinsMavenEventSpy(reporterMustNeverBeInvoked) {
        @Override
        protected boolean isEventSpyDisabled() {
            return true;
        }
    };

    spy.init(new EventSpy.Context() {
        @Override
        public Map<String, Object> getData() {
            return new HashMap<String, Object>();
        }
    });

    DefaultMavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setPom(new File("path/to/pom.xml"));
    request.setGoals(Arrays.asList("clean", "source:jar", "deploy"));

    spy.onEvent(request);
    spy.close();
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:40,代码来源:JenkinsMavenEventSpyDisablementTest.java

示例14: createRequest

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
private MavenExecutionRequest createRequest(File file, List<String> activeProfiles, List<String> inactiveProfiles, List<String> goals) {
  Properties executionProperties = myEmbedderSettings.getProperties();
  if (executionProperties == null) executionProperties = new Properties();

  DefaultEventDispatcher dispatcher = new DefaultEventDispatcher();
  dispatcher.addEventMonitor(new DefaultEventMonitor(myLogger));

  // subclassing because in DefaultMavenExecutionRequest field isRecursive is always false
  MavenExecutionRequest result = new DefaultMavenExecutionRequest(myLocalRepository, mySettings, dispatcher, goals, file.getParent(),
                                                                  createProfileManager(activeProfiles, inactiveProfiles,
                                                                                       executionProperties), executionProperties,
                                                                  new Properties(), true) {
    private boolean myIsRecursive;

    @Override
    public boolean isRecursive() {
      return myIsRecursive;
    }

    @Override
    public void setRecursive(final boolean recursive) {
      myIsRecursive = recursive;
    }
  };

  result.setPomFile(file.getPath());
  result.setRecursive(myEmbedderSettings.isRecursive());

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:MavenEmbedder.java

示例15: newMojo

import org.apache.maven.execution.DefaultMavenExecutionRequest; //导入依赖的package包/类
protected AbstractXmlMojo newMojo( String pDir )
        throws Exception
    {
        File testPom = new File( new File( getBasedir(), pDir ), "pom.xml" );
        
        MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
        ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
        ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class);
        MavenProject project = projectBuilder.build(testPom, buildingRequest).getProject();
//        final Build build = new Build();
//        build.setDirectory( "target" );
//        project.setBuild(build);
        project.getBuild().setDirectory("target");
        AbstractXmlMojo vm = (AbstractXmlMojo) lookupConfiguredMojo(project, getGoal());
        setVariableValueToObject( vm, "basedir", new File( getBasedir(), pDir ) );
        final Log log = new SilentLog();
        DefaultResourceManager rm = new DefaultResourceManager();
        setVariableValueToObject( rm, "logger", log );
        setVariableValueToObject( vm, "locator", rm );
        final Map<String, ResourceLoader> resourceLoaders = new HashMap<String, ResourceLoader>();
        resourceLoaders.put( "file", new FileResourceLoader() );
        resourceLoaders.put( "jar", new JarResourceLoader() );
        resourceLoaders.put( "classloader", new ThreadContextClasspathResourceLoader() );
        URLResourceLoader url = new URLResourceLoader();
        setVariableValueToObject( url, "logger", log );
        resourceLoaders.put( "url", url );
        setVariableValueToObject( rm, "resourceLoaders", resourceLoaders );

//        MavenProjectStub project = new MavenProjectStub()
//        {
//            public Build getBuild()
//            {
//                return build;
//            }
//        };
//        setVariableValueToObject( vm, "project", project );
        return vm;
    }
 
开发者ID:mojohaus,项目名称:xml-maven-plugin,代码行数:39,代码来源:AbstractXmlMojoTestCase.java


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