/*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.examples;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.examples.util.Booter;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResult;
/**
* Resolves a single artifact.
*/
public class ResolveArtifact
{
public static void main( String[] args )
throws Exception
{
System.out.println( "------------------------------------------------------------" );
System.out.println( ResolveArtifact.class.getSimpleName() );
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession( system );
Artifact artifact = new DefaultArtifact( "org.eclipse.aether:aether-util:1.0.0.v20140518" );
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact( artifact );
artifactRequest.setRepositories( Booter.newRepositories( system, session ) );
ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
artifact = artifactResult.getArtifact();
System.out.println( artifact + " resolved to " + artifact.getFile() );
}
}