public static ArtifactRepository buildArtifactRepository( Repository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer container ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); String url = repo.getUrl(); if ( id == null || id.trim().length() < 1 ) { throw new InvalidRepositoryException( "Repository ID must not be empty (URL is: " + url + ").", new IllegalArgumentException( "repository.id" ) ); } if ( url == null || url.trim().length() < 1 ) { throw new InvalidRepositoryException( "Repository URL must not be empty (ID is: " + id + ").", new IllegalArgumentException( "repository.url" ) ); } // TODO: make this a map inside the factory instead, so no lookup needed ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container ); ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshots, releases ); } else { return null; } }
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer container ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); String url = repo.getUrl(); // TODO: make this a map inside the factory instead, so no lookup needed ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container ); return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, repo.isUniqueVersion() ); } else { return null; } }
public void setLocalRepository(final File dir) throws InvalidRepositoryException { assert dir != null; ArtifactRepository repo = repositoryFactory.createLocalRepository(dir); setLocalRepository(repo); }
@Deprecated public ArtifactRepository getMirrorRepository( ArtifactRepository repository ) { Mirror mirror = mirrorSelector.getMirror( repository, legacySupport.getSession().getSettings().getMirrors() ); if ( mirror != null ) { String id = mirror.getId(); if ( id == null ) { // TODO this should be illegal in settings.xml id = repository.getId(); } log.debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" ); repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); } return repository; }
protected ArtifactRepository createDeploymentArtifactRepository(final String id, final String url) { return artifactRepositoryFactory.createDeploymentArtifactRepository(id, url, artifactRepositoryLayout, true); }
private ArtifactRepository getRepository( Settings settings ) { return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + settings.getLocalRepository(), defaultRepositoryLayout, null, null ); }
private ArtifactRepository getDeploymentRepository(ArtifactRepositoryFactory factory, ArtifactRepositoryLayout layout, String repositoryId, String repositoryUrl) throws ComponentLookupException { if (repositoryUrl == null) return null; final ArtifactRepository repository = factory.createDeploymentArtifactRepository( repositoryId, repositoryUrl, layout, uniqueVersion); return new WrappedArtifactRepository(repository, uniqueVersion); }
/** * @param id * Repository ID. This ID has to match the ID in the repository index, due to a design bug in Maven. * @param indexDirectory * Directory that contains exploded index zip file. * @param repository * URL of the Maven repository. Used to resolve artifacts. */ public void addRemoteRepository(String id, File indexDirectory, URL repository) throws IOException, UnsupportedExistingLuceneIndexException { indexer.addIndexingContext(id, id,null, indexDirectory,null,null, NexusIndexer.DEFAULT_INDEX); remoteRepositories.add( arf.createArtifactRepository(id, repository.toExternalForm(), new DefaultRepositoryLayout(), POLICY, POLICY)); }
private ArtifactRepository getArtifactRepository(final String outputDirectory) throws ArtifactNotFoundException, MojoFailureException { return artifactRepositoryFactory.createDeploymentArtifactRepository("tars", "file://" + outputDirectory, getArtifactRepositoryLayout(), false); }
private ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) throws MojoFailureException { // if it's a simple url String id = null; ArtifactRepositoryLayout layout = getLayout("default"); String url = repo; // if it's an extended repo URL of the form id::layout::url if (repo.contains("::")) { Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repo); if (!matcher.matches()) { throw new MojoFailureException(repo, "Invalid syntax for repository: " + repo, "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"."); } id = matcher.group(1).trim(); if (!StringUtils.isEmpty(matcher.group(2))) { layout = getLayout(matcher.group(2).trim()); } url = matcher.group(3).trim(); } return artifactRepositoryFactory.createArtifactRepository(id, url, layout, policy, policy); }
protected List<ArtifactRepository> createSafeRepositories() { List<ArtifactRepository> result = new ArrayList<>(); ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout(); if (this.repositories == null) { this.repositories = new TreeMap<>(); } List<String> ids = new ArrayList<>(this.repositories.keySet()); if (addMavenCentral) { ids.add(0, MAVEN_CENTRAL_ID); this.repositories.put(MAVEN_CENTRAL_ID, MAVEN_CENTRAL_URL); } for (String id : ids) { String url = this.repositories.get(id).trim(); ArtifactRepository repo = artifactRepositoryFactory.createDeploymentArtifactRepository( String.valueOf(id), url, repositoryLayout, true); getLog().info("Will use repository " + repo.getUrl()); if (verbose) { getLog().info(repo.toString()); } result.add(repo); } return result; }
public static ArtifactRepository createRemoteRepository(MavenEmbedder embedder, String url, String id) { try { ArtifactRepositoryFactory fact = (ArtifactRepositoryFactory) embedder.getPlexusContainer().lookup(ArtifactRepositoryFactory.ROLE); ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN); ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN); return fact.createArtifactRepository(id, url, ArtifactRepositoryFactory.DEFAULT_LAYOUT_ID, snapshotsPolicy, releasesPolicy); } catch (UnknownRepositoryLayoutException ex) { Exceptions.printStackTrace(ex); } catch (ComponentLookupException ex) { Exceptions.printStackTrace(ex); } return null; }
protected List<ArtifactRepository> createSafeRepositories() { List<ArtifactRepository> safeRepositories = new ArrayList<ArtifactRepository>(); ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout(); if (repositories == null) { repositories = new TreeMap<String, String>(); } List<String> ids = new ArrayList<String>(repositories.keySet()); if (addMavenCentral) { ids.add(0, MAVEN_CENTRAL_ID); repositories.put(MAVEN_CENTRAL_ID, MAVEN_CENTRAL_URL); } for (String id : ids) { String url = repositories.get(id); url = url.trim(); ArtifactRepository repo; repo = artifactRepositoryFactory.createDeploymentArtifactRepository( String.valueOf(id), url, repositoryLayout, true); getLog().info("Will use repository " + repo.getUrl()); if (verbose) { getLog().info(repo.toString()); } safeRepositories.add(repo); } return safeRepositories; }
public static ArtifactRepository createRemoteRepository(MavenEmbedder embedder, String url, String id) { try { ArtifactRepositoryFactory fact = (ArtifactRepositoryFactory) online.getPlexusContainer().lookup(ArtifactRepositoryFactory.ROLE); ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN); ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN); return fact.createArtifactRepository(id, url, ArtifactRepositoryFactory.DEFAULT_LAYOUT_ID, snapshotsPolicy, releasesPolicy); } catch (UnknownRepositoryLayoutException ex) { Exceptions.printStackTrace(ex); } catch (ComponentLookupException ex) { Exceptions.printStackTrace(ex); } return null; }
return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, repoLayout, true );
private ArtifactRepository getRepository( Settings settings ) { // ---------------------------------------------------------------------- // Set our configured location as the default but try to use the defaults // as returned by the MavenSettings component. // ---------------------------------------------------------------------- String localRepo = localRepository; if ( !( StringUtils.isEmpty( settings.getLocalRepository() ) ) ) { localRepo = settings.getLocalRepository(); } return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + localRepo, repositoryLayout, null, null ); }
protected void installDependencies( final String outputDirectory, final String repositoryName ) throws MojoExecutionException, MojoFailureException { if ( generateRepository ) { // The repo where the jar files will be installed ArtifactRepository artifactRepository = artifactRepositoryFactory.createDeploymentArtifactRepository( "appassembler", "file://" + outputDirectory + "/" + repositoryName, getArtifactRepositoryLayout(), false ); for ( Artifact artifact : artifacts ) { installArtifact( artifact, artifactRepository, this.useTimestampInSnapshotFileName ); } // install the project's artifact in the new repository installArtifact( projectArtifact, artifactRepository ); } } }
public ArtifactRepository createRepository( String url, String repositoryId ) throws ComponentLookupException { // snapshots vs releases // offline = to turning the update policy off //TODO: we'll need to allow finer grained creation of repositories but this will do for now String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS; String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN; ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag ); ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag ); return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy ); }
return repositoryFactory.createDeploymentArtifactRepository(id, url, repoLayout, unique); } else { return repositoryFactory.createDeploymentArtifactRepository( candidate.getId(), candidate.getUrl(),
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered ) throws ConsumerException { repositoryLocation = repository.getLocation(); if ( generatedRepositoryLocation == null ) { generatedRepositoryLocation = new File( repositoryLocation ); } if ( localRepository == null ) { // This is a bit crappy, it would be better to operate entirely within // the base repository, but would need to adjust maven-artifact localRepository = new File( System.getProperty( "user.home" ), ".m2/repository" ); try { localArtifactRepository = artifactRepositoryFactory.createArtifactRepository( "local", localRepository.toURL().toExternalForm(), layout, null, null ); } catch ( MalformedURLException e ) { throw new ConsumerException( e.getMessage(), e ); } } }