當前位置: 首頁>>代碼示例>>Java>>正文


Java ArtifactRepository.pathOf方法代碼示例

本文整理匯總了Java中org.apache.maven.artifact.repository.ArtifactRepository.pathOf方法的典型用法代碼示例。如果您正苦於以下問題:Java ArtifactRepository.pathOf方法的具體用法?Java ArtifactRepository.pathOf怎麽用?Java ArtifactRepository.pathOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.maven.artifact.repository.ArtifactRepository的用法示例。


在下文中一共展示了ArtifactRepository.pathOf方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createArtifact

import org.apache.maven.artifact.repository.ArtifactRepository; //導入方法依賴的package包/類
private static @NonNull Artifact createArtifact(@NonNull NBVersionInfo info, @NullAllowed String classifier) {
    Artifact art;
    MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
    if (info.getClassifier() != null || classifier != null) {
        art = online.createArtifactWithClassifier(info.getGroupId(),
                info.getArtifactId(),
                info.getVersion(),
                info.getType() != null ? info.getType() : "jar", //NOI18N
                classifier == null ? info.getClassifier() : classifier);
    } else {
        art = online.createArtifact(info.getGroupId(),
                info.getArtifactId(),
                info.getVersion(),
                null,
                info.getType() != null ? info.getType() : "jar"); //NOI18N
    }
    ArtifactRepository repo = online.getLocalRepository();
    String localPath = repo.pathOf(art);
    art.setFile(FileUtil.normalizeFile(new File(online.getLocalRepositoryFile(), localPath)));

    return art;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:RepositoryUtil.java

示例2: writeRelocationPom

import org.apache.maven.artifact.repository.ArtifactRepository; //導入方法依賴的package包/類
private void writeRelocationPom( String groupId, String artifactId, String version, String newGroupId,
                                 String newArtifactId, String newVersion, String message,
                                 ArtifactRepository repository, FileTransaction transaction )
    throws IOException
{
    Model pom = new Model();
    pom.setGroupId( groupId );
    pom.setArtifactId( artifactId );
    pom.setVersion( version );

    DistributionManagement dMngt = new DistributionManagement();

    Relocation relocation = new Relocation();
    relocation.setGroupId( newGroupId );
    relocation.setArtifactId( newArtifactId );
    relocation.setVersion( newVersion );
    if ( message != null && message.length() > 0 )
    {
        relocation.setMessage( message );
    }

    dMngt.setRelocation( relocation );

    pom.setDistributionManagement( dMngt );

    Artifact artifact = artifactFactory.createBuildArtifact( groupId, artifactId, version, "pom" ); //$NON-NLS-1$
    File pomFile = new File( repository.getBasedir(), repository.pathOf( artifact ) );

    StringWriter strWriter = new StringWriter();
    MavenXpp3Writer pomWriter = new MavenXpp3Writer();
    pomWriter.write( strWriter, pom );

    transaction.createFile( strWriter.toString(), pomFile, digesters );
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:35,代碼來源:LegacyToDefaultConverter.java

示例3: resolve

import org.apache.maven.artifact.repository.ArtifactRepository; //導入方法依賴的package包/類
public @Override File resolve(Artifact artifact) {
    if (!artifact.getExtension().equals(NbMavenProject.TYPE_POM)) {
        return null;
    }
    if (!artifact.getClassifier().isEmpty()) {
        return null;
    }
    ArtifactRepository local = EmbedderFactory.getProjectEmbedder().getLocalRepository();
    if (local.getLayout() != null) { // #189807: for unknown reasons, there is no layout when running inside MavenCommandLineExecutor.run
        
        //the special snapshot handling is important in case of SNAPSHOT or x-SNAPSHOT versions, for some reason aether has slightly different
        //handling of baseversion compared to maven artifact. we need to manually set the baseversion here..
        boolean isSnapshot = artifact.isSnapshot();
        DefaultArtifact art = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), null, artifact.getExtension(), artifact.getClassifier(), new DefaultArtifactHandler(artifact.getExtension()));
        if (isSnapshot) {
            art.setBaseVersion(artifact.getBaseVersion());
        }
        String path = local.pathOf(art);
        if (new File(local.getBasedir(), path).exists()) {
            return null; // for now, we prefer the repository version when available
        }
    }
    //#234586
    Set<String> gavSet = gav.get();
    if (gavSet == null) {
        gavSet = new HashSet<String>();
        gav.set(gavSet);
    }
    String id = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();

    if (!gavSet.contains(id)) {
        try {
            gavSet.add(id); //#234586
            File pom = MavenFileOwnerQueryImpl.getInstance().getOwnerPOM(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
            if (pom != null) {
                //instead of workarounds down the road, we set the artifact's file here.
                // some stacktraces to maven/aether do set it after querying our code, but some don't for reasons unknown to me.
                artifact.setFile(pom);
                return pom;
            }
        } finally {
            gavSet.remove(id); //#234586
            if (gavSet.isEmpty()) {
                gav.remove();
            }
        }
    } else {
        LOG.log(Level.INFO, "Cycle in NbArtifactFixer resolution (issue #234586): {0}", Arrays.toString(gavSet.toArray()));
    }
    
    try {
        File f = createFallbackPOM(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
        //instead of workarounds down the road, we set the artifact's file here.
        // some stacktraces to maven/aether do set it after querying our code, but some don't for reasons unknown to me.
        artifact.setFile(f);
        return f;
    } catch (IOException x) {
        Exceptions.printStackTrace(x);
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:62,代碼來源:NbArtifactFixer.java

示例4: copyArtifact

import org.apache.maven.artifact.repository.ArtifactRepository; //導入方法依賴的package包/類
private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction )
    throws ArtifactConversionException
{
    File sourceFile = artifact.getFile();

    if ( sourceFile.getAbsolutePath().indexOf( "/plugins/" ) > -1 ) //$NON-NLS-1$
    {
        artifact.setArtifactHandler( artifactHandlerManager.getArtifactHandler( "maven-plugin" ) ); //$NON-NLS-1$
    }

    File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );

    boolean result = true;
    try
    {
        boolean matching = false;
        if ( !force && targetFile.exists() )
        {
            matching = FileUtils.contentEquals( sourceFile, targetFile );
            if ( !matching )
            {
                addWarning( artifact, Messages.getString( "failure.target.already.exists" ) ); //$NON-NLS-1$
                result = false;
            }
        }
        if ( result )
        {
            if ( force || !matching )
            {
                if ( testChecksums( artifact, sourceFile ) )
                {
                    transaction.copyFile( sourceFile, targetFile, digesters );
                }
                else
                {
                    result = false;
                }
            }
        }
    }
    catch ( IOException e )
    {
        throw new ArtifactConversionException( Messages.getString( "error.copying.artifact" ), e ); //$NON-NLS-1$
    }
    return result;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:47,代碼來源:LegacyToDefaultConverter.java

示例5: installArtifact

import org.apache.maven.artifact.repository.ArtifactRepository; //導入方法依賴的package包/類
/**
 * Copy artifact to another repository, with an option not to use timestamp in the snapshot filename.
 * 
 * @param artifact The artifact to install.
 * @param artifactRepository The repository where to install.
 * @param useTimestampInSnapshotFileName Using timestamp for SNAPSHOT's.
 * @throws MojoExecutionException
 */
protected void installArtifact( Artifact artifact, ArtifactRepository artifactRepository,
                                boolean useTimestampInSnapshotFileName )
    throws MojoExecutionException
{
    if ( artifact.getFile() != null )
    {
        try
        {
            // Necessary for the artifact's baseVersion to be set correctly
            // See: http://mail-archives.apache.org/mod_mbox/maven-dev/200511.mbox/%[email protected]%3e
            artifact.isSnapshot();

            File source = artifact.getFile();

            String localPath = artifactRepository.pathOf( artifact );

            File destination = new File( artifactRepository.getBasedir(), localPath );
            if ( !destination.getParentFile().exists() )
            {
                destination.getParentFile().mkdirs();
            }

            if ( artifact.isSnapshot() )
            {
                if ( !useTimestampInSnapshotFileName )
                {
                    // Don't want timestamp in the snapshot file during copy
                    destination = new File( destination.getParentFile(), source.getName() );
                }
            }

            if ( !source.isDirectory() )
            {
                // Sometimes target/classes is in the artifact list and copyFile() would fail.
                // Need to ignore this condition
                FileUtils.copyFile( source, destination );
            }

            getLog().info( "Installing artifact " + source.getPath() + " to " + destination );

        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "Failed to copy artifact.", e );
        }
    }
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:56,代碼來源:AbstractAppAssemblerMojo.java


注:本文中的org.apache.maven.artifact.repository.ArtifactRepository.pathOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。