List of usage examples for org.apache.maven.artifact.repository ArtifactRepository setUrl
void setUrl(String url);
From source file:io.fabric8.maven.DeployToProfileMojo.java
License:Apache License
@SuppressWarnings("unchecked") private void addNeededRemoteRepository() { // TODO: Remove this code when we use releases from Maven Central // included jboss-fs repo which is required until we use an Apache version of Karaf boolean found = false; if (remoteRepositories != null) { for (Object obj : remoteRepositories) { if (obj instanceof ArtifactRepository) { ArtifactRepository repo = (ArtifactRepository) obj; if (repo.getUrl().contains("repository.jboss.org/nexus/content/groups/fs-public")) { found = true;/*from w w w.j ava 2 s . c o m*/ getLog().debug("Found existing (" + repo.getId() + ") remote repository: " + repo.getUrl()); break; } } } } if (!found) { ArtifactRepository fsPublic = new MavenArtifactRepository(); fsPublic.setId("jboss-public-fs"); fsPublic.setUrl("http://repository.jboss.org/nexus/content/groups/fs-public/"); fsPublic.setLayout(new DefaultRepositoryLayout()); fsPublic.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(true, "never", "warn")); fsPublic.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(false, "never", "ignore")); if (remoteRepositories == null) { remoteRepositories = new ArrayList(); } remoteRepositories.add(fsPublic); getLog().info( "Adding needed remote repository: http://repository.jboss.org/nexus/content/groups/fs-public/"); } }
From source file:org.commonjava.maven.ext.cli.Cli.java
License:Apache License
private void createSession(File target, File settings) { try {// ww w . java 2 s .c om final DefaultContainerConfiguration config = new DefaultContainerConfiguration(); config.setClassPathScanning(PlexusConstants.SCANNING_ON); config.setComponentVisibility(PlexusConstants.GLOBAL_VISIBILITY); config.setName("PME-CLI"); PlexusContainer container = new DefaultPlexusContainer(config); pomIO = container.lookup(PomIO.class); session = container.lookup(ManipulationSession.class); manipulationManager = container.lookup(ManipulationManager.class); final MavenExecutionRequest req = new DefaultMavenExecutionRequest() .setUserProperties(System.getProperties()).setUserProperties(userProps) .setRemoteRepositories(Collections.<ArtifactRepository>emptyList()); ArtifactRepository ar = null; if (settings == null) { // No, this is not a typo. If current default is null, supply new local and global. // This function passes in settings to make it easier to test. this.settings = settings = new File(System.getProperty("user.home"), ".m2/settings.xml"); ar = new MavenArtifactRepository(); ar.setUrl("file://" + System.getProperty("user.home") + "/.m2/repository"); req.setLocalRepository(ar); } req.setUserSettingsFile(settings); req.setGlobalSettingsFile(settings); MavenExecutionRequestPopulator executionRequestPopulator = container .lookup(MavenExecutionRequestPopulator.class); executionRequestPopulator.populateFromSettings(req, parseSettings(settings)); executionRequestPopulator.populateDefaults(req); if (ar != null) { ar.setUrl("file://" + req.getLocalRepositoryPath()); } if (userProps != null && userProps.containsKey("maven.repo.local")) { if (ar == null) { ar = new MavenArtifactRepository(); } ar.setUrl("file://" + userProps.getProperty("maven.repo.local")); req.setLocalRepository(ar); } final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult()); mavenSession.getRequest().setPom(target); session.setMavenSession(mavenSession); } catch (ComponentLookupException e) { logger.debug("Caught problem instantiating ", e); System.err.println("Unable to start Cli subsystem"); System.exit(100); } catch (PlexusContainerException e) { logger.debug("Caught problem instantiating ", e); System.err.println("Unable to start Cli subsystem"); System.exit(100); } catch (SettingsBuildingException e) { logger.debug("Caught problem parsing settings file ", e); System.err.println("Unable to parse settings.xml file"); System.exit(100); } catch (MavenExecutionRequestPopulationException e) { logger.debug("Caught problem populating maven request from settings file ", e); System.err.println("Unable to create maven execution request from settings.xml file"); System.exit(100); } }
From source file:org.commonjava.maven.ext.manip.Cli.java
License:Apache License
private void createSession(File target, File settings) { try {/*from w ww .j a v a2 s. c o m*/ PlexusContainer container = new DefaultPlexusContainer(); final MavenExecutionRequest req = new DefaultMavenExecutionRequest() .setUserProperties(System.getProperties()).setUserProperties(userProps) .setRemoteRepositories(Collections.<ArtifactRepository>emptyList()); if (userProps != null && userProps.containsKey("maven.repo.local")) { ArtifactRepository ar = new MavenArtifactRepository(); ar.setUrl("file://" + userProps.getProperty("maven.repo.local")); req.setLocalRepository(ar); } if (settings != null) { req.setUserSettingsFile(settings); req.setGlobalSettingsFile(settings); MavenExecutionRequestPopulator executionRequestPopulator = container .lookup(MavenExecutionRequestPopulator.class); executionRequestPopulator.populateFromSettings(req, parseSettings(settings)); executionRequestPopulator.populateDefaults(req); } final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult()); mavenSession.getRequest().setPom(target); pomIO = container.lookup(PomIO.class); session = container.lookup(ManipulationSession.class); manipulationManager = container.lookup(ManipulationManager.class); session.setMavenSession(mavenSession); } catch (ComponentLookupException e) { logger.debug("Caught problem instantiating ", e); System.err.println("Unable to start Cli subsystem"); System.exit(100); e.printStackTrace(); } catch (PlexusContainerException e) { logger.debug("Caught problem instantiating ", e); System.err.println("Unable to start Cli subsystem"); System.exit(100); } catch (SettingsBuildingException e) { logger.debug("Caught problem parsing settings file ", e); System.err.println("Unable to parse settings.xml file"); System.exit(100); } catch (MavenExecutionRequestPopulationException e) { logger.debug("Caught problem populating maven request from settings file ", e); System.err.println("Unable to create maven execution request from settings.xml file"); System.exit(100); } }