org.eclipse.aether.DefaultRepositorySystemSession Java Examples

The following examples show how to use org.eclipse.aether.DefaultRepositorySystemSession. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AetherFactories.java    From spring-cloud-contract with Apache License 2.0 6 votes vote down vote up
public static RepositorySystemSession newSession(RepositorySystem system,
		boolean workOffline) {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	session.setOffline(workOffline);
	if (!workOffline) {
		session.setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS);
	}
	session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_WARN);
	String localRepositoryDirectory = localRepositoryDirectory(workOffline);
	if (log.isDebugEnabled()) {
		log.debug("Local Repository Directory set to [" + localRepositoryDirectory
				+ "]. Work offline: [" + workOffline + "]");
	}
	LocalRepository localRepo = new LocalRepository(localRepositoryDirectory);
	session.setLocalRepositoryManager(
			system.newLocalRepositoryManager(session, localRepo));
	return session;
}
 
Example #2
Source File: MavenArtifactResolver.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private MavenArtifactResolver(Builder builder) throws BootstrapMavenException {
    final BootstrapMavenContext mvnSettings = new BootstrapMavenContext(builder);
    this.repoSystem = mvnSettings.getRepositorySystem();

    final RepositorySystemSession session = mvnSettings.getRepositorySystemSession();
    if (builder.localRepo != null && builder.reTryFailedResolutionsAgainstDefaultLocalRepo) {
        localRepoManager = new MavenLocalRepositoryManager(
                repoSystem.newLocalRepositoryManager(session, new LocalRepository(builder.localRepo)),
                Paths.get(BootstrapMavenContext.resolveLocalRepo(mvnSettings.getEffectiveSettings())));
        this.repoSession = new DefaultRepositorySystemSession(session).setLocalRepositoryManager(localRepoManager);
    } else {
        this.repoSession = session;
        localRepoManager = null;
    }

    this.remoteRepos = mvnSettings.getRemoteRepositories();
    this.remoteRepoManager = mvnSettings.getRemoteRepositoryManager();
}
 
Example #3
Source File: MavenSettingsReader.java    From spring-init with Apache License 2.0 6 votes vote down vote up
public static void applySettings(MavenSettings settings,
		DefaultRepositorySystemSession session) {
	if (settings.getLocalRepository() != null) {
		try {
			session.setLocalRepositoryManager(
					new SimpleLocalRepositoryManagerFactory().newInstance(session,
							new LocalRepository(settings.getLocalRepository())));
		}
		catch (NoLocalRepositoryManagerException e) {
			throw new IllegalStateException(
					"Cannot set local repository to " + settings.getLocalRepository(),
					e);
		}
	}
	session.setOffline(settings.getOffline());
	session.setMirrorSelector(settings.getMirrorSelector());
	session.setAuthenticationSelector(settings.getAuthenticationSelector());
	session.setProxySelector(settings.getProxySelector());
}
 
Example #4
Source File: NbRepositorySystem.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public CollectResult collectDependencies(RepositorySystemSession session, CollectRequest request) throws DependencyCollectionException {
    DefaultRepositorySystemSession cloned = new DefaultRepositorySystemSession(session);
    DependencyGraphTransformer transformer = session.getDependencyGraphTransformer();
    //need to reset the transformer to prevent the transformation to happen and to it below separately.
    cloned.setDependencyGraphTransformer(null);
    CollectResult res = super.collectDependencies(cloned, request);
    CloningDependencyVisitor vis = new CloningDependencyVisitor();
    res.getRoot().accept(vis);

    //this part copied from DefaultDependencyCollector
    try {
        DefaultDependencyGraphTransformationContext context =
                new DefaultDependencyGraphTransformationContext(session);
        res.setRoot(transformer.transformGraph(res.getRoot(), context));
    } catch (RepositoryException e) {
        res.addException(e);
    }

    if (!res.getExceptions().isEmpty()) {
        throw new DependencyCollectionException(res);
    }
    res.getRoot().setData("NB_TEST", vis.getRootNode());
    return res;
}
 
Example #5
Source File: RepositoryUtility.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
private static DefaultRepositorySystemSession newSession(
    RepositorySystem system, DependencySelector dependencySelector) {
  DefaultRepositorySystemSession session = createDefaultRepositorySystemSession(system);
  session.setDependencySelector(dependencySelector);

  // By default, Maven's MavenRepositorySystemUtils.newSession() returns a session with
  // ChainedDependencyGraphTransformer(ConflictResolver(...), JavaDependencyContextRefiner()).
  // Because the full dependency graph does not resolve conflicts of versions, this session does
  // not use ConflictResolver.
  session.setDependencyGraphTransformer(
      new ChainedDependencyGraphTransformer(
          new CycleBreakerGraphTransformer(), // Avoids StackOverflowError
          new JavaDependencyContextRefiner()));

  // No dependency management in the full dependency graph
  session.setDependencyManager(null);

  return session;
}
 
Example #6
Source File: DependencyResolver.java    From spring-init with Apache License 2.0 6 votes vote down vote up
private DefaultRepositorySystemSession createSession(Properties properties)
		throws NoLocalRepositoryManagerException {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	LocalRepository repository = localRepository(properties);
	session.setLocalRepositoryManager(
			localRepositoryManagerFactory.newInstance(session, repository));
	applySettings(session);
	ProxySelector existing = session.getProxySelector();
	if (existing == null || !(existing instanceof CompositeProxySelector)) {
		JreProxySelector fallback = new JreProxySelector();
		ProxySelector selector = existing == null ? fallback
				: new CompositeProxySelector(Arrays.asList(existing, fallback));
		session.setProxySelector(selector);
	}
	return session;
}
 
Example #7
Source File: DependencyGraphBuilder.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
private DependencyGraph buildDependencyGraph(
    List<DependencyNode> dependencyNodes, DefaultRepositorySystemSession session) {
   
  try {
    DependencyNode node = resolveCompileTimeDependencies(dependencyNodes, session);
    return DependencyGraph.from(node);
  } catch (DependencyResolutionException ex) {
    DependencyResult result = ex.getResult();
    DependencyGraph graph = DependencyGraph.from(result.getRoot());

    for (ArtifactResult artifactResult : result.getArtifactResults()) {
      Artifact resolvedArtifact = artifactResult.getArtifact();

      if (resolvedArtifact == null) {
        Artifact requestedArtifact = artifactResult.getRequest().getArtifact();
        graph.addUnresolvableArtifactProblem(requestedArtifact);
      }
    }
    
    return graph;
  }
}
 
Example #8
Source File: MavenSystemManager.java    From archiva with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new aether repository system session for the given directory and assigns the
 * repository to this session.
 *
 * @param localRepoDir The repository directory
 * @return The newly created session object.
 */
public static RepositorySystemSession newRepositorySystemSession(String localRepoDir) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

    LocalRepository repo = new LocalRepository(localRepoDir);

    DependencySelector depFilter = new AndDependencySelector(new ExclusionDependencySelector());
    session.setDependencySelector(depFilter);
    SimpleLocalRepositoryManagerFactory repFactory = new SimpleLocalRepositoryManagerFactory();
    try {
        LocalRepositoryManager manager = repFactory.newInstance(session, repo);
        session.setLocalRepositoryManager(manager);
    } catch (NoLocalRepositoryManagerException e) {
        log.error("Could not assign the repository manager to the session: {}", e.getMessage(), e);
    }

    return session;
}
 
Example #9
Source File: MavenSettingsReader.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
public static void applySettings(MavenSettings settings,
		DefaultRepositorySystemSession session) {
	if (settings.getLocalRepository() != null) {
		try {
			session.setLocalRepositoryManager(
					new SimpleLocalRepositoryManagerFactory().newInstance(session,
							new LocalRepository(settings.getLocalRepository())));
		}
		catch (NoLocalRepositoryManagerException e) {
			throw new IllegalStateException(
					"Cannot set local repository to " + settings.getLocalRepository(),
					e);
		}
	}
	session.setOffline(settings.getOffline());
	session.setMirrorSelector(settings.getMirrorSelector());
	session.setAuthenticationSelector(settings.getAuthenticationSelector());
	session.setProxySelector(settings.getProxySelector());
}
 
Example #10
Source File: InitializeMojoTest.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
private InitializeMojo createMojoInstance() throws PlexusContainerException {
    InitializeMojo mojo = new InitializeMojo();
    mojo.project = new MavenProject();
    mojo.repositorySystem = new DefaultRepositorySystem();
    mojo.repositorySystemSession = new DefaultRepositorySystemSession();
    mojo.buildPluginManager = new DefaultBuildPluginManager();
    mojo.container = new DefaultPlexusContainer(new DefaultContainerConfiguration());
    mojo.mavenSession = new MavenSession(mojo.container, mojo.repositorySystemSession, new DefaultMavenExecutionRequest(),
        new DefaultMavenExecutionResult());

    mojo.lifecycleExecutor = new DefaultLifecycleExecutor();
    mojo.scmManager = new DefaultScmManager();
    mojo.remoteRepositories = Collections.emptyList();
    mojo.projectBuildDir = OUT.getAbsolutePath();

    Build build = new Build();
    build.setOutputDirectory(OUT.getAbsolutePath());
    mojo.project.setBuild(build);

    return mojo;
}
 
Example #11
Source File: MavenPluginRepository.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system, File localRepoFile, Settings settings) {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	if (!settings.getMirrors().isEmpty()) {
		DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
		for (Mirror mirror : settings.getMirrors()) {
			mirrorSelector.add(mirror.getId(), mirror.getUrl(), "default", true, mirror.getMirrorOf(), "*");
		}
		session.setMirrorSelector(mirrorSelector);
	}
	session.setProxySelector(proxySelector);

	LocalRepository localRepo = new LocalRepository(localRepoFile);
	session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

	return session;
}
 
Example #12
Source File: DependencyResolver.java    From start.spring.io with Apache License 2.0 6 votes vote down vote up
DependencyResolver() {
	try {
		ServiceLocator serviceLocator = createServiceLocator();
		DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
		session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(false, false));
		this.localRepositoryLocation = Files.createTempDirectory("metadata-validation-m2");
		LocalRepository localRepository = new LocalRepository(this.localRepositoryLocation.toFile());
		this.repositorySystem = serviceLocator.getService(RepositorySystem.class);
		session.setLocalRepositoryManager(
				this.repositorySystem.newLocalRepositoryManager(session, localRepository));
		session.setReadOnly();
		this.repositorySystemSession = session;
	}
	catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
Example #13
Source File: Publisher.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * @param toPublish each {@link Artifact} must contain a file, that will be published under maven
 *     coordinates in the corresponding {@link Artifact}.
 * @see Artifact#setFile
 */
public DeployResult publish(List<Artifact> toPublish) throws DeploymentException {
  RepositorySystem repoSys = Objects.requireNonNull(locator.getService(RepositorySystem.class));

  DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
  session.setLocalRepositoryManager(repoSys.newLocalRepositoryManager(session, localRepo));
  session.setReadOnly();

  DeployRequest deployRequest = createDeployRequest(toPublish);

  if (dryRun) {
    return new DeployResult(deployRequest)
        .setArtifacts(toPublish)
        .setMetadata(deployRequest.getMetadata());
  } else {
    return repoSys.deploy(session, deployRequest);
  }
}
 
Example #14
Source File: JavaFXRunMojoTestCase.java    From javafx-maven-plugin with Apache License 2.0 6 votes vote down vote up
private void setUpProject(File pomFile, AbstractMojo mojo) throws Exception {
    super.setUp();

    MockitoAnnotations.initMocks(this);

    ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class);
    buildingRequest.setResolveDependencies(true);
    when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
    DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
    repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
            .newInstance(repositorySession, new LocalRepository(RepositorySystem.defaultUserLocalRepository)));
    when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);

    ProjectBuilder builder = lookup(ProjectBuilder.class);
    ProjectBuildingResult build = builder.build(pomFile, buildingRequest);
    MavenProject project = build.getProject();

    project.getBuild().setOutputDirectory(new File( "target/test-classes").getAbsolutePath());
    setVariableValueToObject(mojo, "project", project);
}
 
Example #15
Source File: RemotePluginRepository.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public static DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

	LocalRepository localRepo = new LocalRepository("target/local-repo");
	session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

	session.setTransferListener(new ConsoleTransferListener());
	session.setRepositoryListener(new ConsoleRepositoryListener());

	// uncomment to generate dirty trees
	// session.setDependencyGraphTransformer( null );

	return session;
}
 
Example #16
Source File: ArtifactTransporter.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

    LocalRepository localRepo = new LocalRepository(localRepositoryLocation.toAbsolutePath().toString());
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

    session.setTransferListener(new ConsoleTransferListener());
    session.setRepositoryListener(new ConsoleRepositoryListener());

    return session;
}
 
Example #17
Source File: MavenContainer.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public DefaultRepositorySystemSession setupRepoSession(final RepositorySystem repoSystem, final Settings settings)
{
   DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
   session.setOffline(false);

   Proxy activeProxy = settings.getActiveProxy();
   if (activeProxy != null)
   {
      DefaultProxySelector dps = new DefaultProxySelector();
      dps.add(convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
      session.setProxySelector(dps);
   }

   final DefaultMirrorSelector mirrorSelector = createMirrorSelector(settings);
   final LazyAuthenticationSelector authSelector = createAuthSelector(settings, mirrorSelector);

   session.setMirrorSelector(mirrorSelector);
   session.setAuthenticationSelector(authSelector);

   LocalRepository localRepo = new LocalRepository(new File(settings.getLocalRepository()));
   session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo));
   session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
   session.setCache(new DefaultRepositoryCache());
   boolean cacheNotFoundArtifacts = true;
   boolean cacheTransferErrors = true;
   session.setResolutionErrorPolicy(new SimpleResolutionErrorPolicy(cacheNotFoundArtifacts, cacheTransferErrors));
   session.setWorkspaceReader(new ClasspathWorkspaceReader());
   if (Boolean.getBoolean("org.apache.maven.log_transfer"))
   {
      session.setTransferListener(new JULMavenTransferListener());
   }
   return session;
}
 
Example #18
Source File: AetherUtils.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private RepositorySystemSession getRepositorySystemSession(RepositorySystem system, String  localRepositoryPath) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

    LocalRepository localRepo = new LocalRepository(localRepositoryPath);
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

    return session;
}
 
Example #19
Source File: MavenAddonDependencyResolver.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Response<String> resolveAPIVersion(AddonId addonId)
{
   RepositorySystem system = container.getRepositorySystem();
   Settings settings = getSettings();
   DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
   return resolveAPIVersion(addonId, system, settings, session);
}
 
Example #20
Source File: RepositoryHandler.java    From maven-repository-tools with Eclipse Public License 1.0 5 votes vote down vote up
public static DefaultRepositorySystemSession getRepositorySystemSession( RepositorySystem system, 
                                                                         File localRepoPath )
{
    if ( session == null )
    {
        session = newRepositorySystemSession( system, localRepoPath );
    }
    return session;
}
 
Example #21
Source File: ProjectHelper.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public Model loadPomFromFile(File pomFile, String... profiles)
{
   RepositorySystem system = mavenContainer.getRepositorySystem();
   Settings settings = mavenContainer.getSettings();
   DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
   final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest()
            .setSystemProperties(System.getProperties())
            .setPomFile(pomFile)
            .setActiveProfileIds(settings.getActiveProfiles());
   ModelBuilder builder = new DefaultModelBuilderFactory().newInstance();
   ModelBuildingResult result;
   try
   {
      request.setModelResolver(new MavenModelResolver(system, session,
               MavenRepositories.getRemoteRepositories(mavenContainer, settings)));
      result = builder.build(request);
   }
   // wrap exception message
   catch (ModelBuildingException e)
   {
      String pomPath = request.getPomFile().getAbsolutePath();
      StringBuilder sb = new StringBuilder("Found ").append(e.getProblems().size())
               .append(" problems while building POM model from ").append(pomPath).append("\n");

      int counter = 1;
      for (ModelProblem problem : e.getProblems())
      {
         sb.append(counter++).append("/ ").append(problem).append("\n");
      }

      throw new RuntimeException(sb.toString());
   }
   return result.getEffectiveModel();
}
 
Example #22
Source File: InstallDeployTest.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
private MavenProject readMavenProject(File basedir, Properties properties) throws Exception {
  File pom = new File(basedir, "pom.xml");
  MavenExecutionRequest request = new DefaultMavenExecutionRequest();
  request.setUserProperties(properties);
  request.setBaseDirectory(basedir);
  ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
  configuration.setRepositorySession(new DefaultRepositorySystemSession());
  MavenProject project = mojos.lookup(ProjectBuilder.class).build(pom, configuration).getProject();
  Assert.assertNotNull(project);
  return project;
}
 
Example #23
Source File: Cadfael.java    From Poseidon with Apache License 2.0 5 votes vote down vote up
private RepositorySystemSession newSession(RepositorySystem system) {
        DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
        LocalRepository localRepo = new LocalRepository("target/local-repo");
        session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
        // set possible proxies and mirrors
//        session.setProxySelector(new DefaultProxySelector().add(new Proxy(Proxy.TYPE_HTTP, "host", 3625), Arrays.asList("localhost", "127.0.0.1")));
//        session.setMirrorSelector(new DefaultMirrorSelector().add("my-mirror", "http://mirror", "default", false, "external:*", null));
        return session;
    }
 
Example #24
Source File: MavenUtil.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public static DefaultRepositorySystemSession newRepositorySystemSession ( final RepositorySystem system )
{
    final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession ();

    final LocalRepository localRepo = new LocalRepository ( "target/local-repo" );
    session.setLocalRepositoryManager ( system.newLocalRepositoryManager ( session, localRepo ) );

    return session;
}
 
Example #25
Source File: Helper.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public static DefaultRepositorySystemSession newRepositorySystemSession ( final Path tempDir, final RepositorySystem system )
{
    final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession ();

    final LocalRepository localRepo = new LocalRepository ( tempDir.toFile () );
    session.setLocalRepositoryManager ( system.newLocalRepositoryManager ( session, localRepo ) );

    session.setTransferListener ( new LoggerTransferListener () );
    session.setConfigProperty ( ConfigurationProperties.USER_AGENT, VersionInformation.USER_AGENT );

    session.setConfigProperty ( ConfigurationProperties.CONNECT_TIMEOUT, Integer.getInteger ( "drone.aether.connectTimeout", 30_000 ) );

    return session;
}
 
Example #26
Source File: MavenResolverDependencyManagementVersionResolver.java    From initializr with Apache License 2.0 5 votes vote down vote up
MavenResolverDependencyManagementVersionResolver(Path cacheLocation) {
	ServiceLocator serviceLocator = createServiceLocator();
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(false, false));
	LocalRepository localRepository = new LocalRepository(cacheLocation.toFile());
	this.repositorySystem = serviceLocator.getService(RepositorySystem.class);
	session.setLocalRepositoryManager(this.repositorySystem.newLocalRepositoryManager(session, localRepository));
	session.setReadOnly();
	this.repositorySystemSession = session;
}
 
Example #27
Source File: AbstractWildFlyMojoTest.java    From wildfly-maven-plugin with GNU Lesser General Public License v2.1 5 votes vote down vote up
public MavenProject readMavenProject(Path pom)
        throws Exception {
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setBaseDirectory(pom.getParent().toFile());
    ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
    configuration.setRepositorySession(new DefaultRepositorySystemSession());
    MavenProject project = rule.lookup(ProjectBuilder.class).build(pom.toFile(), configuration).getProject();
    Assert.assertNotNull(project);
    return project;
}
 
Example #28
Source File: DependencyResolver.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
private ProjectBuildingRequest getProjectBuildingRequest(Properties properties)
		throws NoLocalRepositoryManagerException {
	DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
	DefaultRepositorySystemSession session = createSession(properties);
	projectBuildingRequest.setRepositoryMerging(RepositoryMerging.REQUEST_DOMINANT);
	projectBuildingRequest.setRemoteRepositories(mavenRepositories(properties));
	projectBuildingRequest.getRemoteRepositories()
			.addAll(mavenRepositories(this.settings));
	projectBuildingRequest.setRepositorySession(session);
	projectBuildingRequest.setProcessPlugins(false);
	projectBuildingRequest.setBuildStartTime(new Date());
	projectBuildingRequest.setUserProperties(properties);
	projectBuildingRequest.setSystemProperties(System.getProperties());
	return projectBuildingRequest;
}
 
Example #29
Source File: MavenInitializer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public static RepositorySystemSession newSession(RepositorySystem system) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

    LocalRepository localRepo = new LocalRepository(localRepoLocation());
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

    return session;
}
 
Example #30
Source File: CodeGenMojoTest.java    From copybook4java with MIT License 5 votes vote down vote up
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);
}