@Override public String getBasedir() { return ( userLocalArtifactRepository != null ) ? userLocalArtifactRepository.getBasedir() : null; }
@Override public MavenExecutionRequest setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; if ( localRepository != null ) { setLocalRepositoryPath( new File( localRepository.getBasedir() ).getAbsoluteFile() ); } return this; }
private Date getLocalCopyLastModified( ArtifactRepository localRepository, RepositoryMetadata metadata ) { String metadataPath = localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ); File metadataFile = new File( localRepository.getBasedir(), metadataPath ); return metadataFile.isFile() ? new Date( metadataFile.lastModified() ) : null; }
@Override public Artifact find( Artifact artifact ) { File artifactFile = new File( localRepository.getBasedir(), pathOf( artifact ) ); // We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal // with multiple local repository implementations yet. artifact.setFile( artifactFile ); return artifact; }
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() ); }
public void updateVersion( String version, ArtifactRepository localRepository ) { setResolvedVersion( version ); setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) ); }
public void updateVersion( String version, ArtifactRepository localRepository ) { setResolvedVersion( version ); setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) ); }
private FixedStringSearchInterpolator createRepositoryInterpolator() { final Properties settingsProperties = new Properties(); final MavenSession session = getMavenSession(); if (getLocalRepository() != null) { settingsProperties.setProperty("localRepository", getLocalRepository().getBasedir()); settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir()); } else if (session != null && session.getSettings() != null) { settingsProperties.setProperty("localRepository", session.getSettings().getLocalRepository() ); settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir() ); } return FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(settingsProperties)); }
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException { File destination = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); // ---------------------------------------------------------------------------- // I'm fully aware that the file could just be moved using File.rename but // there are bugs in various JVM that have problems doing this across // different filesystem. So we'll incur the small hit to actually copy // here and be safe. jvz. // ---------------------------------------------------------------------------- try { FileUtils.copyFile( file, destination ); } catch ( IOException e ) { throw new RepositoryMetadataStoreException( "Error copying POM to the local repository.", e ); } }
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException { File f = transformedFile == null ? originalFile : transformedFile; if ( f == null ) { return; } File destination = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); // ---------------------------------------------------------------------------- // I'm fully aware that the file could just be moved using File.rename but // there are bugs in various JVM that have problems doing this across // different filesystem. So we'll incur the small hit to actually copy // here and be safe. jvz. // ---------------------------------------------------------------------------- try { FileUtils.copyFile( f, destination ); } catch ( IOException e ) { throw new RepositoryMetadataStoreException( "Error copying POM to the local repository.", e ); } }
private File getLocalMavenRepoFile(MavenSession session, File source) { ArtifactRepository localRepo = session.getLocalRepository(); if (localRepo == null) { log.warn("No local repo found so not adding any extra watches in the local repository"); return null; } Artifact artifact = getArtifactFromJar(source); if (artifact != null) { try { return new File(localRepo.getBasedir(), localRepo.pathOf(artifact)); } catch (InvalidArtifactRTException e) { log.warn("Cannot get the local repository path for %s in base dir %s : %s", artifact, localRepo.getBasedir(), e.getMessage()); } } return null; }
public static RepositorySystemSession overlay( ArtifactRepository repository, RepositorySystemSession session, RepositorySystem system ) { if ( repository == null || repository.getBasedir() == null ) { return session; } if ( session != null ) { LocalRepositoryManager lrm = session.getLocalRepositoryManager(); if ( lrm != null && lrm.getRepository().getBasedir().equals( new File( repository.getBasedir() ) ) ) { return session; } } else { session = new DefaultRepositorySystemSession(); } final LocalRepositoryManager llrm = new LegacyLocalRepositoryManager( repository ); return new DefaultRepositorySystemSession( session ).setLocalRepositoryManager( llrm ); }
new File( localRepo.getBasedir(), localRepo.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) );
private void localRepository( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException { // ------------------------------------------------------------------------ // Local Repository // // 1. Use a value has been passed in via the configuration // 2. Use value in the resultant settings // 3. Use default value // ------------------------------------------------------------------------ if ( request.getLocalRepository() == null ) { request.setLocalRepository( createLocalRepository( request ) ); } if ( request.getLocalRepositoryPath() == null ) { request.setLocalRepositoryPath( new File( request.getLocalRepository().getBasedir() ).getAbsoluteFile() ); } }
File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) );
file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) );
new File( localRepo.getBasedir(), localRepo.pathOfLocalRepositoryMetadata( metadata, repository ) ); boolean update;
LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
/** * Gets the path of the specified artifact metadata within the local repository. Note that the returned path need * not exist (yet). * * @param metadata The artifact metadata whose local repo path should be determined, must not be <code>null</code>. * @return The absolute path to the artifact metadata when installed, never <code>null</code>. */ protected File getLocalRepoFile( ArtifactMetadata metadata ) { String path = localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ); return new File( localRepository.getBasedir(), path ); }