@Override public ArtifactRepositoryLayout getLayout() { return userLocalArtifactRepository.getLayout(); }
public UserLocalArtifactRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; setLayout( localRepository.getLayout() ); }
public static String getLayout( ArtifactRepository repo ) { try { return repo.getLayout().getId(); } catch ( LinkageError e ) { /* * NOTE: getId() was added in 3.x and is as such not implemented by plugins compiled against 2.x APIs. */ String className = repo.getLayout().getClass().getSimpleName(); if ( className.endsWith( "RepositoryLayout" ) ) { String layout = className.substring( 0, className.length() - "RepositoryLayout".length() ); if ( layout.length() > 0 ) { layout = Character.toLowerCase( layout.charAt( 0 ) ) + layout.substring( 1 ); return layout; } } return ""; } }
private LegacyLocalRepositoryManager( ArtifactRepository delegate ) { this.delegate = Objects.requireNonNull( delegate, "delegate cannot be null" ); ArtifactRepositoryLayout layout = delegate.getLayout(); repo = new LocalRepository( new File( delegate.getBasedir() ), ( layout != null ) ? layout.getClass().getSimpleName() : "legacy" ); /* * NOTE: "invoker:install" vs "appassembler:assemble": Both mojos use the artifact installer to put an artifact * into a repository. In the first case, the result needs to be a proper local repository that one can use for * local artifact resolution. In the second case, the result needs to precisely obey the path information of the * repository's layout to allow pointing at artifacts within the repository. Unfortunately, * DefaultRepositoryLayout does not correctly describe the layout of a local repository which unlike a remote * repository never uses timestamps in the filename of a snapshot artifact. The discrepancy gets notable when a * remotely resolved snapshot artifact gets passed into pathOf(). So producing a proper local artifact path * using DefaultRepositoryLayout requires us to enforce usage of the artifact's base version. This * transformation however contradicts the other use case of precisely obeying the repository's layout. The below * flag tries to detect which use case applies to make both plugins happy. */ realLocalRepo = ( layout instanceof DefaultRepositoryLayout ) && "local".equals( delegate.getId() ); }
createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(), snapshotPolicy, releasePolicy );
createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(), snapshotPolicy, releasePolicy );
private void injectMirror( ArtifactRepository repository, Mirror mirror ) { if ( mirror != null ) { ArtifactRepository original = createArtifactRepository( repository.getId(), repository.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); repository.setMirroredRepositories( Collections.singletonList( original ) ); repository.setId( mirror.getId() ); repository.setUrl( mirror.getUrl() ); if ( StringUtils.isNotEmpty( mirror.getLayout() ) ) { repository.setLayout( getLayout( mirror.getLayout() ) ); } } }
private void injectMirror( ArtifactRepository repository, Mirror mirror ) { if ( mirror != null ) { ArtifactRepository original = createArtifactRepository( repository.getId(), repository.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); repository.setMirroredRepositories( Collections.singletonList( original ) ); repository.setId( mirror.getId() ); repository.setUrl( mirror.getUrl() ); if ( StringUtils.isNotEmpty( mirror.getLayout() ) ) { repository.setLayout( getLayout( mirror.getLayout() ) ); } } }
@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; }
public ArtifactRepositoryLayout getLayout() { return artifactRepository.getLayout(); } public void setLayout( ArtifactRepositoryLayout layout )
public ArtifactRepositoryLayout getLayout() { return artifactRepository.getLayout(); } public void setLayout( ArtifactRepositoryLayout layout )
public static String getLayout(ArtifactRepository repo) { try { return repo.getLayout().getId(); } catch (LinkageError e) { /* * NOTE: getId() was added in 3.x and is as such not implemented by plugins compiled against 2.x APIs. */ String className = repo.getLayout().getClass().getSimpleName(); if (className.endsWith("RepositoryLayout")) { String layout = className.substring(0, className.length() - "RepositoryLayout".length()); if (layout.length() > 0) { layout = Character.toLowerCase(layout.charAt(0)) + layout.substring(1); return layout; } } return ""; } }
public static String getLayout(ArtifactRepository repo) { try { return repo.getLayout().getId(); } catch (LinkageError e) { /* * NOTE: getId() was added in 3.x and is as such not implemented by plugins compiled against 2.x APIs. */ String className = repo.getLayout().getClass().getSimpleName(); if (className.endsWith("RepositoryLayout")) { String layout = className.substring(0, className.length() - "RepositoryLayout".length()); if (layout.length() > 0) { layout = Character.toLowerCase(layout.charAt(0)) + layout.substring(1); return layout; } } return ""; } }
private boolean isPrefixMirrorOf(ArtifactRepository repo, Mirror mirror) { boolean isMirrorOfRepoUrl = repo.getUrl() != null && repo.getUrl().startsWith(mirror.getMirrorOf()); boolean matchesLayout = repo.getLayout() != null && repo.getLayout().getId().equals(mirror.getMirrorOfLayouts()); return isMirrorOfRepoUrl && matchesLayout; }
static boolean matchesLayout( ArtifactRepository repository, Mirror mirror ) { return matchesLayout( repository.getLayout().getId(), mirror.getMirrorOfLayouts() ); }
private void addEntireP2RepositoryToTargetPlatform(ArtifactRepository repository, TargetPlatformConfigurationStub resolutionContext) { try { if (repository.getLayout() instanceof P2ArtifactRepositoryLayout) { URI url = new URL(repository.getUrl()).toURI(); resolutionContext.addP2Repository(new MavenRepositoryLocation(repository.getId(), url)); getLogger().debug("Added p2 repository " + repository.getId() + " (" + repository.getUrl() + ")"); } } catch (MalformedURLException e) { throw new RuntimeException("Invalid repository URL: " + repository.getUrl(), e); } catch (URISyntaxException e) { throw new RuntimeException("Invalid repository URL: " + repository.getUrl(), e); } }
private RemoteRepository remote(ArtifactRepository input) { return new RemoteRepository.Builder(input.getId(), input.getLayout().getId(), input.getUrl()).setSnapshotPolicy(policy(input.getSnapshots())) .setReleasePolicy(policy(input.getReleases())).build(); }
public ArtifactRepository getMirrorRepository( ArtifactRepository repository ) { ArtifactRepository mirror = getMirror( repository ); if ( mirror != null ) { String id = mirror.getId(); if ( id == null ) { // TODO: this should be illegal in settings.xml id = repository.getId(); } getLogger().debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" ); repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); } return repository; }
private RemoteRepository remote(ArtifactRepository input) { Proxy proxy = proxy(input); Builder builder = new RemoteRepository.Builder(input.getId(), input.getLayout().getId(), input.getUrl()) .setSnapshotPolicy(policy(input.getSnapshots())) .setReleasePolicy(policy(input.getReleases())); if (proxy != null) { builder = builder.setProxy(proxy); } return builder.build(); }
private RemoteRepository convertToArtifactRepository(final org.apache.maven.artifact.repository.ArtifactRepository artifactRepository) { final MavenEmbedder mavenEmbedder = MavenProjectLoader.newMavenEmbedder(MavenSettings.getSettings().isOffline()); final RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(artifactRepository.getId(), artifactRepository.getLayout().getId(), artifactRepository.getUrl()) .setSnapshotPolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)) .setReleasePolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_WARN)); final Settings settings = MavenSettings.getSettings(); final Server server = settings.getServer(artifactRepository.getId()); if (server != null) { final Authentication authentication = mavenEmbedder .getMavenSession() .getRepositorySession() .getAuthenticationSelector() .getAuthentication(remoteRepoBuilder.build()); remoteRepoBuilder.setAuthentication(authentication); } return remoteRepoBuilder.build(); } }