Source:
private static void doDeploy(File content, File pomFile, String localRepository, String repositoryId, String repositoryUrl, String userName, String password, String groupId, String artifactId, String classifier, String extension, String version) throws Exception { DefaultRepositorySystemSession session = null; RepositorySystem system = MavenLibraryResolverProvider.newRepositorySystem(); session = newRepositorySystemSession(localRepository); DeployRequest deployRequest = new DeployRequest(); Artifact jarArtifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version); jarArtifact = jarArtifact.setFile(content); deployRequest.addArtifact(jarArtifact); if (pomFile == null) { String strClassifier = classifier == null ? "" : ("-" + classifier); String pomPath = localRepository + "/" + groupId.replaceAll("\\.", "/") + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + strClassifier + "." + "pom"; pomFile = new File(pomPath); } ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer(); IRepositoryArtifactHandler hander = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer); String type = null; if (hander != null) { ArtifactRepositoryBean artifactServerBean = hander.getArtifactServerBean(); type = artifactServerBean.getType(); } if (pomFile.exists() && (!StringUtils.equals("pom", extension) || StringUtils.equalsIgnoreCase("Artifactory", type))) { Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom"); pomArtifact = pomArtifact.setFile(pomFile); deployRequest.addArtifact(pomArtifact); } Authentication auth = new AuthenticationBuilder().addUsername(userName).addPassword(password).build(); RemoteRepository distRepo = new RemoteRepository.Builder(repositoryId, "default", repositoryUrl).setAuthentication(auth) .build(); distRepo = new RemoteRepository.Builder(distRepo).setProxy(new TalendAetherProxySelector().getProxy(distRepo)).build(); deployRequest.setRepository(distRepo); system.deploy(session, deployRequest); }

Target:
private static void doDeploy(File content, File pomFile, String localRepository, String repositoryId, String repositoryUrl, String userName, String password, String groupId, String artifactId, String classifier, String extension, String version) throws Exception { DefaultRepositorySystemSession session = null; RepositorySystem system = MavenLibraryResolverProvider.newRepositorySystem(); session = newRepositorySystemSession(localRepository); DeployRequest deployRequest = new DeployRequest(); Artifact jarArtifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version); jarArtifact = jarArtifact.setFile(content); deployRequest.addArtifact(jarArtifact); if (pomFile == null) { String strClassifier = classifier == null ? "" : ("-" + classifier); String pomPath = localRepository + "/" + groupId.replaceAll("\\.", "/") + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + strClassifier + "." + "pom"; pomFile = new File(pomPath); } if (pomFile.exists()) { Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom"); pomArtifact = pomArtifact.setFile(pomFile); deployRequest.addArtifact(pomArtifact); } Authentication auth = new AuthenticationBuilder().addUsername(userName).addPassword(password).build(); RemoteRepository distRepo = new RemoteRepository.Builder(repositoryId, "default", repositoryUrl).setAuthentication(auth) .build(); distRepo = new RemoteRepository.Builder(distRepo).setProxy(new TalendAetherProxySelector().getProxy(distRepo)).build(); deployRequest.setRepository(distRepo); system.deploy(session, deployRequest); }