request.addArtifact( mainArtifact ); request.addArtifact( pomArtifact );
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 ); }
@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); } }
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 ); }
Path target = Paths.get(project.getBuild().getDirectory()).resolve(project.getBuild().getFinalName() + ".zip"); IoUtils.copy(zippedFP, target); installReq.addArtifact(artifact); if (pomFile != null && Files.exists(pomFile.toPath())) { Artifact pomArtifact = new SubArtifact(artifact, "", "pom"); pomArtifact = pomArtifact.setFile(pomFile); installReq.addArtifact(pomArtifact);
Path target = Paths.get(project.getBuild().getDirectory()).resolve(project.getBuild().getFinalName() + ".zip"); IoUtils.copy(zippedFP, target); installReq.addArtifact(artifact); if (pomFile != null && Files.exists(pomFile.toPath())) { Artifact pomArtifact = new SubArtifact(artifact, "", "pom"); pomArtifact = pomArtifact.setFile(pomFile); installReq.addArtifact(pomArtifact);
installRequest.addArtifact(artifact); installRequest.addArtifact(artifact); installRequest.addArtifact(pomArtifact); installRequest.addArtifact(AetherUtils.toArtifact(attachedArtifact));
installRequest.addArtifact(artifact); installRequest.addArtifact(artifact); installRequest.addArtifact(pomArtifact); installRequest.addArtifact(AetherUtils.toArtifact(attachedArtifact));
null, file); request.addArtifact(artifact);
@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); } }
/** * 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 ); } }
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); } }
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; } }
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); }