repoSystem.install( session, request );
@Override public void install(ArtifactCoords coords, Path file) throws ArtifactException { final InstallRequest request = new InstallRequest(); request.addArtifact(new DefaultArtifact(coords.getGroupId(), coords.getArtifactId(), coords.getClassifier(), coords.getExtension(), coords.getVersion(), Collections.emptyMap(), file.toFile())); try { repoSystem.install(session, request); } catch (InstallationException ex) { Logger.getLogger(MavenArtifactRepositoryManager.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Installs a file as artifact to a local repository. * * @param spec <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version> * @param file artifact file * @throws InstallationException */ public void install(String spec, File file) throws InstallationException { InstallRequest request = new InstallRequest(); Artifact artifact = new DefaultArtifact(spec).setFile(file); request.setArtifacts(ImmutableList.of(artifact)); repositorySystem.install(session, request); }
public static void main( String[] args ) throws Exception { System.out.println( "------------------------------------------------------------" ); System.out.println( InstallArtifacts.class.getSimpleName() ); RepositorySystem system = Booter.newRepositorySystem(); RepositorySystemSession session = Booter.newRepositorySystemSession( system ); Artifact jarArtifact = new DefaultArtifact( "test", "org.eclipse.aether.examples", "", "jar", "0.1-SNAPSHOT" ); jarArtifact = jarArtifact.setFile( new File( "src/main/data/demo.jar" ) ); Artifact pomArtifact = new SubArtifact( jarArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( new File( "pom.xml" ) ); InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact( jarArtifact ).addArtifact( pomArtifact ); system.install( session, installRequest ); }
public void install( Artifact artifact, Artifact pom ) throws InstallationException { RepositorySystemSession session = newSession(); InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact( artifact ).addArtifact( pom ); repositorySystem.install( session, installRequest ); }
repositorySystem.install(repositorySession, request);
@Override public void deploy(final String pom, Artifact... artifacts) { try { final InstallRequest installRequest = new InstallRequest(); for (Artifact artifact : artifacts) { installRequest .addArtifact(artifact); } Aether.getAether().getSystem().install(Aether.getAether().getSession(), installRequest); } catch (InstallationException e) { throw new RuntimeException(e); } }
@Override public void deploy(final String pom, Artifact... artifacts) { try { final InstallRequest installRequest = new InstallRequest(); for (Artifact artifact : artifacts) { installRequest .addArtifact(artifact); } Aether.getAether().getSystem().install(Aether.getAether().getSession(), installRequest); } catch (InstallationException e) { throw new RuntimeException(e); } }
@Override public void deploy(final String pom, Artifact... artifacts) { try { final InstallRequest installRequest = new InstallRequest(); for (Artifact artifact : artifacts) { installRequest .addArtifact(artifact); } Aether.getAether().getSystem().install(Aether.getAether().getSession(), installRequest); } catch (InstallationException e) { throw new RuntimeException(e); } }
@Override public void install(MavenArtifact coords, Path path) throws MavenUniverseException { final InstallRequest request = new InstallRequest(); request.addArtifact(new DefaultArtifact(coords.getGroupId(), coords.getArtifactId(), coords.getClassifier(), coords.getExtension(), coords.getVersion(), Collections.emptyMap(), path.toFile())); try { repoSystem.install(getSession(), request); } catch (InstallationException ex) { throw new MavenUniverseException("Failed to install " + coords.getCoordsAsString(), ex); } }
repositorySystem.install(repositorySystemSession, installRequest); } catch (InstallationException e) { throw new MojoExecutionException(e.getMessage(), e);
repositorySystem.install(repositorySystemSession, installRequest); } catch (InstallationException e) { throw new MojoExecutionException(e.getMessage(), e);
private boolean deployTestJar(Artifact jarArtifact, RepositorySystemSession session) throws InstallationException { final InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact(jarArtifact); InstallResult result = Aether.getAether().getSystem().install(session, installRequest); return result.getArtifacts().size() == 1; } }
public void installArtifact(String groupId, String artifactId, String ext, String classifier, String version, File artifactFile, File pomFile) throws Exception { Artifact jarArtifact = new DefaultArtifact(groupId, artifactId, classifier, ext, version); jarArtifact = jarArtifact.setFile(artifactFile); Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom"); pomArtifact = pomArtifact.setFile(pomFile); InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact(jarArtifact ).addArtifact( pomArtifact ); InstallResult result = system.install(session, installRequest); if (!result.getArtifacts().contains(jarArtifact)) { throw new AssertionError("Could not install jar " + jarArtifact); } if (!result.getArtifacts().contains(pomArtifact)) { throw new AssertionError("Could not install pom " + jarArtifact); } }
when(repositorySystem.install(any(RepositorySystemSession.class), any(InstallRequest.class))) .thenAnswer(new Answer<InstallResult>() {
/** * Installs the given jar into the local repository. * * @param releaseId The releaseId with which the kjar will be installed * @param jar The jar to be installed * @param pomfile The pom file to be installed together with the kjar */ public void installArtifact( AFReleaseId releaseId, File jar, File pomfile ) { Artifact jarArtifact = new DefaultArtifact( releaseId.getGroupId(), releaseId.getArtifactId(), "jar", releaseId.getVersion() ); jarArtifact = jarArtifact.setFile( jar ); Artifact pomArtifact = new SubArtifact( jarArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( pomfile ); InstallRequest installRequest = new InstallRequest(); installRequest .addArtifact( jarArtifact ) .addArtifact( pomArtifact ); try { aether.getSystem().install( aether.getSession(), installRequest ); } catch (InstallationException e) { throw new RuntimeException( e ); } }
/** * Installs the given jar into the local repository. * * @param releaseId The releaseId with which the kjar will be installed * @param jar The jar to be installed * @param pomfile The pom file to be installed together with the kjar */ public void installArtifact( AFReleaseId releaseId, File jar, File pomfile ) { Artifact jarArtifact = new DefaultArtifact( releaseId.getGroupId(), releaseId.getArtifactId(), "jar", releaseId.getVersion() ); jarArtifact = jarArtifact.setFile( jar ); Artifact pomArtifact = new SubArtifact( jarArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( pomfile ); InstallRequest installRequest = new InstallRequest(); installRequest .addArtifact( jarArtifact ) .addArtifact( pomArtifact ); try { aether.getSystem().install( aether.getSession(), installRequest ); } catch (InstallationException e) { throw new RuntimeException( e ); } }
private void installArtifactLocally(final String groupId, final String artifactId, final String version) throws Exception { Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "pom", version); final Path pom = getPom(groupId, artifactId, version); pomArtifact = pomArtifact.setFile(pom.toFile()); final InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact(pomArtifact); final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); RepositorySystem system = locator.getService(RepositorySystem.class); final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); final LocalRepository localRepo = new LocalRepository(m2Folder); session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo)); system.install(session, installRequest); }
private void installArtifactLocally(final String groupId, final String artifactId, final String version) throws Exception { Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "pom", version); final Path pom = getPom(groupId, artifactId, version); pomArtifact = pomArtifact.setFile(pom.toFile()); final InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact(pomArtifact); final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); RepositorySystem system = locator.getService(RepositorySystem.class); final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); final LocalRepository localRepo = new LocalRepository(m2Folder); session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo)); system.install(session, installRequest); }
protected void uploadArtifact(String groupId, String artifactId, String version, String extension, String classifier, File artifactFile, String repositoryUrl) throws Exception { DefaultServiceLocator defaultServiceLocator = MavenRepositorySystemUtils.newServiceLocator(); defaultServiceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); defaultServiceLocator.addService(TransporterFactory.class, FileTransporterFactory.class); defaultServiceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class); RepositorySystem repositorySystem = defaultServiceLocator.getService(RepositorySystem.class); DefaultRepositorySystemSession repositorySystemSession = MavenRepositorySystemUtils.newSession(); LocalRepository localRepository = new LocalRepository(System.getProperty("user.home") + "/.m2/repository"); LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(repositorySystemSession, localRepository); repositorySystemSession.setLocalRepositoryManager(localRepositoryManager); repositorySystemSession.setTransferListener(new ConsoleTransferListener(System.out)); repositorySystemSession.setRepositoryListener(new ConsoleRepositoryListener(System.out)); RemoteRepository remoteRepository = new RemoteRepository.Builder("sdeployer", "default", repositoryUrl).build(); Artifact artifact; if (classifier != null) { artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version); } else { artifact = new DefaultArtifact(groupId, artifactId, extension, version); } artifact = artifact.setFile(artifactFile); InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact(artifact); repositorySystem.install(repositorySystemSession, installRequest); DeployRequest deployRequest = new DeployRequest(); deployRequest.addArtifact(artifact); deployRequest.setRepository(remoteRepository); repositorySystem.deploy(repositorySystemSession, deployRequest); }