Package org.eclipse.aether.artifact

Examples of org.eclipse.aether.artifact.Artifact


         RepositorySystem maven = container.getRepositorySystem();
         Settings settings = container.getSettings();

         DefaultRepositorySystemSession session = container.setupRepoSession(maven, settings);
         Artifact artifact = MavenConvertUtils.coordinateToMavenArtifact(dep);

         List<RemoteRepository> remoteRepos = MavenRepositories.getRemoteRepositories(container, settings, query);

         VersionRangeRequest rangeRequest = new VersionRangeRequest(artifact, remoteRepos, null);
View Full Code Here


      Settings settings = container.getSettings();

      List<RemoteRepository> remoteRepos = MavenRepositories.getRemoteRepositories(container, settings, query);

      DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
      Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());
      ArtifactRequest request = new ArtifactRequest(queryArtifact, remoteRepos, null);
      try
      {
         ArtifactResult resolvedArtifact = system.resolveArtifact(session, request);
         Artifact artifact = resolvedArtifact.getArtifact();

         @SuppressWarnings("unchecked")
         FileResource<?> artifactResource = factory.create(FileResource.class, artifact.getFile());

         return DependencyBuilder.create()
                  .setArtifact(artifactResource)
                  .setGroupId(artifact.getGroupId())
                  .setArtifactId(artifact.getArtifactId())
                  .setClassifier(artifact.getClassifier())
                  .setPackaging(artifact.getExtension())
                  .setVersion(artifact.getBaseVersion());
      }
      catch (ArtifactResolutionException e)
      {
         throw new MavenOperationException(e);
      }
View Full Code Here

            }
         });
         session.setDependencySelector(new ScopeDependencySelector("test"));

         final CoordinateBuilder coord = CoordinateBuilder.create(query.getCoordinate());
         Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(coord);

         List<RemoteRepository> remoteRepos = MavenRepositories.getRemoteRepositories(container, settings, query);
         CollectRequest collectRequest = new CollectRequest(new org.eclipse.aether.graph.Dependency(queryArtifact,
                  null), remoteRepos);
View Full Code Here

         RepositorySystem system = container.getRepositorySystem();
         Settings settings = container.getSettings();

         DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
         Artifact artifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());

         List<RemoteRepository> mavenRepositories = MavenRepositories.getRemoteRepositories(container, settings, query);
         ArtifactDescriptorRequest ar = new ArtifactDescriptorRequest(artifact, mavenRepositories, null);
         ArtifactDescriptorResult results = system.readArtifactDescriptor(session, ar);

         Artifact a = results.getArtifact();
         Dependency d = DependencyBuilder.create().setArtifactId(a.getArtifactId()).setGroupId(a.getGroupId())
                  .setVersion(a.getBaseVersion());

         return new DependencyMetadataImpl(d, results);
      }
      catch (Exception e)
      {
View Full Code Here

            fos.close();
        } catch ( IOException e ) {
            throw new RuntimeException( e );
        }
        //pom.xml Artifact
        Artifact pomXMLArtifact = new DefaultArtifact( gav.getGroupId(),
                                                    gav.getArtifactId(),
                                                    "pom",
                                                    gav.getVersion() );
        pomXMLArtifact = pomXMLArtifact.setFile( pomXMLFile );

        try {
            //Install into local repository
            final InstallRequest installRequest = new InstallRequest();
            installRequest
View Full Code Here

        } catch ( IOException e ) {
            throw new RuntimeException( e );
        }

        //JAR Artifact
        Artifact jarArtifact = new DefaultArtifact( gav.getGroupId(),
                                                    gav.getArtifactId(),
                                                    "jar",
                                                    gav.getVersion() );
        jarArtifact = jarArtifact.setFile( jarFile );

        //pom.xml Artifact
        Artifact pomXMLArtifact = new SubArtifact( jarArtifact,
                                                   "",
                                                   "pom" );
        pomXMLArtifact = pomXMLArtifact.setFile( pomXMLFile );

        try {
            //Install into local repository
            final InstallRequest installRequest = new InstallRequest();
            installRequest
                    .addArtifact( jarArtifact )
                    .addArtifact( pomXMLArtifact );

            Aether.getAether().getSystem().install( Aether.getAether().getSession(),
                                                    installRequest );
        } catch ( InstallationException e ) {
            throw new RuntimeException( e );
        }

        //Deploy into Workbench's default remote repository
        try {
            final DeployRequest deployRequest = new DeployRequest();
            deployRequest
                    .addArtifact( jarArtifact )
                    .addArtifact( pomXMLArtifact )
                    .setRepository( getGuvnorM2Repository() );

            Aether.getAether().getSystem().deploy( Aether.getAether().getSession(),
                                                   deployRequest );

        } catch ( DeploymentException e ) {
            throw new RuntimeException( e );
        }

        //Only deploy to additional repositories if required. This flag is principally for Unit Tests
        if ( !includeAdditionalRepositories ) {
            return;
        }

        //Deploy into remote repository defined in <distributionManagement>
        try {
            final Model model = new MavenXpp3Reader().read( new StringReader( pomXML ) );
            final DistributionManagement distributionManagement = model.getDistributionManagement();

            if ( distributionManagement != null ) {

                final boolean isSnapshot = pomXMLArtifact.isSnapshot();
                DeploymentRepository remoteRepository = null;
                if ( isSnapshot ) {
                    remoteRepository = distributionManagement.getSnapshotRepository();
                } else {
                    remoteRepository = distributionManagement.getRepository();
View Full Code Here

        return this.artifactToMvn(toArtifact(artifact));
    }

    @Override
    public String artifactToMvn(Object _artifact) {
        Artifact artifact = (Artifact) _artifact;
        String bundleName;
        if (artifact.getExtension().equals("jar") && MavenUtil.isEmpty(artifact.getClassifier())) {
            bundleName = String.format("mvn:%s/%s/%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion());
        } else {
            if (MavenUtil.isEmpty(artifact.getClassifier())) {
                bundleName = String.format("mvn:%s/%s/%s/%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getExtension());
            } else {
                bundleName = String.format("mvn:%s/%s/%s/%s/%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getExtension(), artifact.getClassifier());
            }
        }
        return bundleName;
    }
View Full Code Here

                {
                    throw new IllegalStateException( "Failed to discover components in extension realm "
                        + extensionRealm.getId(), e );
                }

                Artifact extensionArtifact = artifacts.get( 0 );
                try
                {
                    extensionDescriptor = extensionDescriptorBuilder.build( extensionArtifact.getFile() );
                }
                catch ( IOException e )
                {
                    String message = "Invalid extension descriptor for " + plugin.getId() + ": " + e.getMessage();
                    if ( logger.isDebugEnabled() )
View Full Code Here

    public Artifact resolve( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
        throws PluginResolutionException
    {
        RequestTrace trace = RequestTrace.newChild( null, plugin );

        Artifact pluginArtifact = toArtifact( plugin, session );

        try
        {
            DefaultRepositorySystemSession pluginSession = new DefaultRepositorySystemSession( session );
            pluginSession.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, false ) );

            ArtifactDescriptorRequest request =
                new ArtifactDescriptorRequest( pluginArtifact, repositories, REPOSITORY_CONTEXT );
            request.setTrace( trace );
            ArtifactDescriptorResult result = repoSystem.readArtifactDescriptor( pluginSession, request );

            pluginArtifact = result.getArtifact();

            String requiredMavenVersion = (String) result.getProperties().get( "prerequisites.maven" );
            if ( requiredMavenVersion != null )
            {
                Map<String, String> props = new LinkedHashMap<String, String>( pluginArtifact.getProperties() );
                props.put( "requiredMavenVersion", requiredMavenVersion );
                pluginArtifact = pluginArtifact.setProperties( props );
            }
        }
        catch ( ArtifactDescriptorException e )
        {
            throw new PluginResolutionException( plugin, e );
View Full Code Here

    public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
        throws RepositoryException
    {
        if ( findPlexusUtils( node ) == null )
        {
            Artifact pu = new DefaultArtifact( GID, AID, null, EXT, VER );
            DefaultDependencyNode child = new DefaultDependencyNode( new Dependency( pu, JavaScopes.RUNTIME ) );
            child.setRepositories( node.getRepositories() );
            child.setRequestContext( node.getRequestContext() );
            node.getChildren().add( child );
        }
View Full Code Here

TOP

Related Classes of org.eclipse.aether.artifact.Artifact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.