try result = repoSystem.deploy( session, request );
public void deploy(RepositorySystemSession session, DeployRequest deployRequest) throws DeploymentException { repoSystem.deploy(session, deployRequest); }
public void deploy(RepositorySystemSession session, DeployRequest deployRequest) throws DeploymentException { repoSystem.deploy(session, deployRequest); }
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" ) ); RemoteRepository distRepo = new RemoteRepository.Builder( "org.eclipse.aether.examples", "default", new File( "target/dist-repo" ).toURI().toString() ).build(); DeployRequest deployRequest = new DeployRequest(); deployRequest.addArtifact( jarArtifact ).addArtifact( pomArtifact ); deployRequest.setRepository( distRepo ); system.deploy( session, deployRequest );
@Override public void deploy(ArtifactCoords coords, Path file) throws ArtifactException { final DeployRequest request = new DeployRequest(); request.addArtifact(new DefaultArtifact(coords.getGroupId(), coords.getArtifactId(), coords.getClassifier(), coords.getExtension(), coords.getVersion(), Collections.emptyMap(), file.toFile())); try { repoSystem.deploy(session, request); } catch (DeploymentException ex) { Logger.getLogger(MavenArtifactRepositoryManager.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Deploys a file as artifact to a remote repository. * * @param spec <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version> * @param file artifact file * @throws DeploymentException */ public void deploy(String spec, File file) throws DeploymentException { DeployRequest request = new DeployRequest(); Artifact artifact = new DefaultArtifact(spec); artifact.setFile(file); request.setArtifacts(ImmutableList.of(artifact)); repositorySystem.deploy(session, request); }
public static void main( String[] args ) throws Exception { System.out.println( "------------------------------------------------------------" ); System.out.println( DeployArtifacts.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" ) ); RemoteRepository distRepo = new RemoteRepository.Builder( "org.eclipse.aether.examples", "default", new File( "target/dist-repo" ).toURI().toString() ).build(); DeployRequest deployRequest = new DeployRequest(); deployRequest.addArtifact( jarArtifact ).addArtifact( pomArtifact ); deployRequest.setRepository( distRepo ); system.deploy( session, deployRequest ); }
@Test public void testDeployArtifactFilteredOutAllRepositories() throws Exception { final GAV gav = new GAV("org.kie.guvnor", "guvnor-m2repo-editor-backend", "0.0.1-SNAPSHOT"); final InputStream is = this.getClass().getResourceAsStream("guvnor-m2repo-editor-backend-test-with-distribution-management.jar"); repo.deployArtifact(is, gav, true, (repo) -> false); verify(repositorySystem, never()).deploy(any(RepositorySystemSession.class), any()); }
@Test public void testDeployArtifactFilteredOutAllRepositories() throws Exception { final GAV gav = new GAV("org.kie.guvnor", "guvnor-m2repo-editor-backend", "0.0.1-SNAPSHOT"); final InputStream is = this.getClass().getResourceAsStream("guvnor-m2repo-editor-backend-test-with-distribution-management.jar"); repo.deployArtifact(is, gav, true, (repo) -> false); verify(repositorySystem, never()).deploy(any(RepositorySystemSession.class), any()); }
@Override public void deploy(final String pom, final Artifact... artifacts) { try { final DeployRequest deployRequest = new DeployRequest(); for (Artifact artifact : artifacts) { deployRequest.addArtifact(artifact); } deployRequest.setRepository(getRepository()); Aether.getAether().getSystem().deploy(Aether.getAether().getSession(), deployRequest); } catch (DeploymentException e) { throw new RuntimeException(e); } }
@Override public void deploy(final String pom, final Artifact... artifacts) { try { final DeployRequest deployRequest = new DeployRequest(); for (Artifact artifact : artifacts) { deployRequest.addArtifact(artifact); } deployRequest.setRepository(getRepository()); Aether.getAether().getSystem().deploy(Aether.getAether().getSession(), deployRequest); } catch (DeploymentException e) { throw new RuntimeException(e); } }
@Override public void deploy(final String pom, final Artifact... artifacts) { try { final DeployRequest deployRequest = new DeployRequest(); for (Artifact artifact : artifacts) { deployRequest.addArtifact(artifact); } deployRequest.setRepository(getRepository()); Aether.getAether().getSystem().deploy(Aether.getAether().getSession(), deployRequest); } catch (DeploymentException e) { throw new RuntimeException(e); } }
public void deployPomArtifact( String groupId, String artifactId, String version, File pomfile ) { Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "pom", version ); pomArtifact = pomArtifact.setFile( pomfile ); DeployRequest deployRequest = new DeployRequest(); deployRequest .addArtifact( pomArtifact ) .setRepository( aether.getLocalRepository() ); try { aether.getSystem().deploy( aether.getSession(), deployRequest ); } catch ( DeploymentException e ) { throw new RuntimeException( e ); } }
public void deployPomArtifact( String groupId, String artifactId, String version, File pomfile ) { Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "pom", version ); pomArtifact = pomArtifact.setFile( pomfile ); DeployRequest deployRequest = new DeployRequest(); deployRequest .addArtifact( pomArtifact ) .setRepository( aether.getLocalRepository() ); try { aether.getSystem().deploy( aether.getSession(), deployRequest ); } catch ( DeploymentException e ) { throw new RuntimeException( e ); } }
/** * You'll usually pass one jar artifact and the corresponding pom artifact. * @param pluginName null if you deploy normal artifacts; none-null for Maven Plugins, that you wish to add a plugin mapping for; * specifies the plugin name in this case. * See http://svn.apache.org/viewvc/maven/plugin-tools/tags/maven-plugin-tools-3.2/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java?revision=1406624&view=markup */ // CHECKSTYLE:ON public void deploy(RemoteRepository target, String pluginName, List<Artifact> artifacts) throws DeploymentException { DeployRequest request; GroupRepositoryMetadata gm; String prefix; request = new DeployRequest(); for (Artifact artifact : artifacts) { if (artifact.getFile() == null) { throw new IllegalArgumentException(artifact.toString() + " without file"); } request.addArtifact(artifact); if (pluginName != null) { gm = new GroupRepositoryMetadata(artifact.getGroupId()); prefix = getGoalPrefixFromArtifactId(artifact.getArtifactId()); gm.addPluginMapping(prefix, artifact.getArtifactId(), pluginName); request.addMetadata(new MetadataBridge(gm)); } } request.setRepository(target); repositorySystem.deploy(repositorySession, request); }
embedder)); Aether.getAether().getSystem().deploy(Aether.getAether().getSession(), remoteRequest);
public void deploy( Artifact artifact, Artifact pom, String remoteRepository ) throws DeploymentException { RepositorySystemSession session = newSession(); Authentication auth = new AuthenticationBuilder().addUsername( "admin" ).addPassword( "admin123" ).build(); RemoteRepository nexus = new RemoteRepository.Builder( "nexus", "default", remoteRepository ).setAuthentication( auth ).build(); DeployRequest deployRequest = new DeployRequest(); deployRequest.addArtifact( artifact ).addArtifact( pom ); deployRequest.setRepository( nexus ); repositorySystem.deploy( session, deployRequest ); }
/** * Deploys a jar on a remote repository. * * @param repository The remote repository where the kjar will be deployed * @param releaseId The releaseId with which the deployment will be made * @param jar The jar to be deployed * @param pomfile The pom file to be deployed together with the kjar */ public void deployArtifact( RemoteRepository repository, 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 ); DeployRequest deployRequest = new DeployRequest(); deployRequest .addArtifact( jarArtifact ) .addArtifact( pomArtifact ) .setRepository( repository ); try { aether.getSystem().deploy( aether.getSession(), deployRequest ); } catch ( DeploymentException e ) { throw new RuntimeException( e ); } }
/** * Deploys a jar on a remote repository. * * @param repository The remote repository where the kjar will be deployed * @param releaseId The releaseId with which the deployment will be made * @param jar The jar to be deployed * @param pomfile The pom file to be deployed together with the kjar */ public void deployArtifact( RemoteRepository repository, 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 ); DeployRequest deployRequest = new DeployRequest(); deployRequest .addArtifact( jarArtifact ) .addArtifact( pomArtifact ) .setRepository( repository ); try { aether.getSystem().deploy( aether.getSession(), deployRequest ); } catch ( DeploymentException e ) { throw new RuntimeException( e ); } }
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); }