/** * Method updateDeploymentRepository * * @param value * @param element * @param counter * @param xmlTag */ protected void updateDeploymentRepository( DeploymentRepository value, String xmlTag, Counter counter, Element element ) { boolean shouldExist = value != null; Element root = updateElement( counter, element, xmlTag, shouldExist ); if ( shouldExist ) { Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "uniqueVersion", value.isUniqueVersion() ? null : String.valueOf( value.isUniqueVersion() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" ); } }
public static void addDistributionManagement(Model pomModel) { DistributionManagement distributionManagement = new DistributionManagement(); DeploymentRepository releaseRepo = new DeploymentRepository(); releaseRepo.setId("repo.spring.io"); releaseRepo.setName("Spring Release Repository"); releaseRepo.setUrl("https://repo.spring.io/libs-release-local"); distributionManagement.setRepository(releaseRepo); DeploymentRepository snapshotRepo = new DeploymentRepository(); snapshotRepo.setId("repo.spring.io"); snapshotRepo.setName("Spring Snapshot Repository"); snapshotRepo.setUrl("https://repo.spring.io/libs-snapshot-local"); distributionManagement.setSnapshotRepository(snapshotRepo); pomModel.setDistributionManagement(distributionManagement); }
public static void addProfiles(Model pomModel) { Profile profile = new Profile(); profile.setId("milestone"); DistributionManagement milestoneDistManagement = new DistributionManagement(); DeploymentRepository milestoneRepo = new DeploymentRepository(); milestoneRepo.setId("repo.spring.io"); milestoneRepo.setName("Spring Milestone Repository"); milestoneRepo.setUrl("https://repo.spring.io/libs-milestone-local"); milestoneDistManagement.setRepository(milestoneRepo); profile.setDistributionManagement(milestoneDistManagement); List<Profile> profiles = new ArrayList<>(); profiles.add(profile); profiles.add(centralProfile()); pomModel.setProfiles(profiles); }
private void visitDistributionManagementRepository( ModelVisitor visitor, DeploymentRepository deploymentRepository ) { RepositoryPolicy releases = deploymentRepository.getReleases(); if ( releases != null ) { visitor.visitDistributionManagementRepositoryRelease( releases ); releases = visitor.replaceDistributionManagementRepositoryRelease( releases ); deploymentRepository.setReleases( releases ); } RepositoryPolicy snapshots = deploymentRepository.getSnapshots(); if ( snapshots != null ) { visitor.visitDistributionManagementRepositorySnapshot( snapshots ); snapshots = visitor.replaceDistributionManagementRepositorySnapshot( snapshots ); deploymentRepository.setSnapshots( snapshots ); } }
private void visitDistributionManagementSnapshotRepository( ModelVisitor visitor, DeploymentRepository deploymentRepository ) { RepositoryPolicy releases = deploymentRepository.getReleases(); if ( releases != null ) { visitor.visitDistributionManagementSnapshotRepositoryRelease( releases ); releases = visitor.replaceDistributionManagementSnapshotRepositoryRelease( releases ); deploymentRepository.setReleases( releases ); } RepositoryPolicy snapshots = deploymentRepository.getSnapshots(); if ( snapshots != null ) { visitor.visitDistributionManagementSnapshotRepositorySnapshot( snapshots ); snapshots = visitor.replaceDistributionManagementSnapshotRepositorySnapshot( snapshots ); deploymentRepository.setSnapshots( snapshots ); } }
private void visitProfileDistributionManagementRepository( ModelVisitor visitor, DeploymentRepository deploymentRepository ) { RepositoryPolicy releases = deploymentRepository.getReleases(); if ( releases != null ) { visitor.visitProfileDistributionManagementRepositoryRelease( releases ); releases = visitor.replaceProfileDistributionManagementRepositoryRelease( releases ); deploymentRepository.setReleases( releases ); } RepositoryPolicy snapshots = deploymentRepository.getSnapshots(); if ( snapshots != null ) { visitor.visitProfileDistributionManagementRepositorySnapshot( snapshots ); snapshots = visitor.replaceProfileDistributionManagementRepositorySnapshot( snapshots ); deploymentRepository.setSnapshots( snapshots ); } }
private void visitProfileDistributionManagementSnapshotRepository( ModelVisitor visitor, DeploymentRepository deploymentRepository ) { RepositoryPolicy releases = deploymentRepository.getReleases(); if ( releases != null ) { visitor.visitProfileDistributionManagementSnapshotRepositoryRelease( releases ); releases = visitor.replaceProfileDistributionManagementSnapshotRepositoryRelease( releases ); deploymentRepository.setReleases( releases ); } RepositoryPolicy snapshots = deploymentRepository.getSnapshots(); if ( snapshots != null ) { visitor.visitProfileDistributionManagementSnapshotRepositorySnapshot( snapshots ); snapshots = visitor.replaceProfileDistributionManagementSnapshotRepositorySnapshot( snapshots ); deploymentRepository.setSnapshots( snapshots ); } }
private RemoteRepository getRemoteRepoFromDeployment(final DeploymentRepository repo, final MavenEmbedder embedder) { RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(repo.getId(), repo.getLayout(), repo .getUrl()) .setSnapshotPolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)) .setReleasePolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_WARN)); Settings settings = MavenSettings.getSettings(); Server server = settings.getServer(repo.getId()); if (server != null) { Authentication authentication = embedder.getMavenSession().getRepositorySession() .getAuthenticationSelector() .getAuthentication(remoteRepoBuilder.build()); remoteRepoBuilder.setAuthentication(authentication); } return remoteRepoBuilder.build(); }
private static RemoteRepository getRemoteRepoFromDeployment(final DeploymentRepository deploymentRepository, final RepositorySystemSession mavenSession) { final RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(deploymentRepository.getId(), deploymentRepository.getLayout(), deploymentRepository.getUrl()) .setSnapshotPolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)) .setReleasePolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)); final Settings settings = MavenSettings.getSettings(); final Server server = settings.getServer(deploymentRepository.getId()); if (server != null) { final Authentication authentication = mavenSession .getAuthenticationSelector() .getAuthentication(remoteRepoBuilder.build()); remoteRepoBuilder.setAuthentication(authentication); } return remoteRepoBuilder.build(); }
private void deployApiProject(File apiPom) throws MojoExecutionException { boolean snapshot = project.getVersion().endsWith("-SNAPSHOT"); DeploymentRepository repo = snapshot ? snapshotRepository : repository; try { executeMojo(// DEPLOY_PLUGIN,// goal("deploy-file"),// configuration(// element("pomFile", apiPom.getAbsolutePath()),// element("file", apiArtifactJarFile().getAbsolutePath()),// element("version", project.getVersion()),// element("repositoryId", repo.getId()),// element("url", repo.getUrl()),// element("repositoryLayout", repo.getLayout()),// element("uniqueVersion", "" + repo.isUniqueVersion())// ),// executionEnvironment(project, session, pluginManager)// ); } catch (MojoExecutionException e) { throw new MojoExecutionException("Problem deploying the api.jar, maybe src/api/pom.xml is invalid", e.getCause()); } }
private void writeDeploymentRepository(DeploymentRepository deploymentRepository, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (deploymentRepository.isUniqueVersion() != true) { writeValue(serializer, "uniqueVersion", String.valueOf(deploymentRepository.isUniqueVersion()), deploymentRepository); } if (deploymentRepository.getReleases() != null) { writeRepositoryPolicy((RepositoryPolicy) deploymentRepository.getReleases(), "releases", serializer); } if (deploymentRepository.getSnapshots() != null) { writeRepositoryPolicy((RepositoryPolicy) deploymentRepository.getSnapshots(), "snapshots", serializer); } if (deploymentRepository.getId() != null) { writeValue(serializer, "id", deploymentRepository.getId(), deploymentRepository); } if (deploymentRepository.getName() != null) { writeValue(serializer, "name", deploymentRepository.getName(), deploymentRepository); } if (deploymentRepository.getUrl() != null) { writeValue(serializer, "url", deploymentRepository.getUrl(), deploymentRepository); } if ((deploymentRepository.getLayout() != null) && !deploymentRepository.getLayout().equals("default")) { writeValue(serializer, "layout", deploymentRepository.getLayout(), deploymentRepository); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(deploymentRepository, "", start, b.length()); }
private void writeDistributionManagement(DistributionManagement distributionManagement, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (distributionManagement.getRepository() != null) { writeDeploymentRepository((DeploymentRepository) distributionManagement.getRepository(), "repository", serializer); } if (distributionManagement.getSnapshotRepository() != null) { writeDeploymentRepository((DeploymentRepository) distributionManagement.getSnapshotRepository(), "snapshotRepository", serializer); } if (distributionManagement.getSite() != null) { writeSite((Site) distributionManagement.getSite(), "site", serializer); } if (distributionManagement.getDownloadUrl() != null) { writeValue(serializer, "downloadUrl", distributionManagement.getDownloadUrl(), distributionManagement); } if (distributionManagement.getRelocation() != null) { writeRelocation((Relocation) distributionManagement.getRelocation(), "relocation", serializer); } if (distributionManagement.getStatus() != null) { writeValue(serializer, "status", distributionManagement.getStatus(), distributionManagement); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(distributionManagement, "", start, b.length()); }
private void visitDistributionManagement( ModelVisitor visitor, DistributionManagement distributionManagement ) { DeploymentRepository repository = distributionManagement.getRepository(); if ( repository != null ) { visitor.visitDistributionManagementRepository( repository ); visitDistributionManagementRepository( visitor, repository ); repository = visitor.replaceDistributionManagementRepository( repository ); distributionManagement.setRepository( repository ); } DeploymentRepository snapshotRepository = distributionManagement.getSnapshotRepository(); if ( snapshotRepository != null ) { visitor.visitDistributionManagementSnapshotRepository( snapshotRepository ); visitDistributionManagementSnapshotRepository( visitor, snapshotRepository ); snapshotRepository = visitor.replaceDistributionManagementSnapshotRepository( snapshotRepository ); distributionManagement.setSnapshotRepository( snapshotRepository ); } Site site = distributionManagement.getSite(); if ( site != null ) { visitor.visitDistributionManagementSite( site ); site = visitor.replaceDistributionManagementSite( site ); distributionManagement.setSite( site ); } Relocation relocation = distributionManagement.getRelocation(); if ( relocation != null ) { visitor.visitDistributionManagementRelocation( relocation ); relocation = visitor.replaceDistributionManagementRelocation( relocation ); distributionManagement.setRelocation( relocation ); } }
private void visitProfileDistributionManagement( ModelVisitor visitor, DistributionManagement distributionManagement ) { DeploymentRepository repository = distributionManagement.getRepository(); if ( repository != null ) { visitor.visitProfileDistributionManagementRepository( repository ); visitProfileDistributionManagementRepository( visitor, repository ); repository = visitor.replaceProfileDistributionManagementRepository( repository ); distributionManagement.setRepository( repository ); } DeploymentRepository snapshotRepository = distributionManagement.getSnapshotRepository(); if ( snapshotRepository != null ) { visitor.visitProfileDistributionManagementSnapshotRepository( snapshotRepository ); visitProfileDistributionManagementSnapshotRepository( visitor, snapshotRepository ); snapshotRepository = visitor.replaceProfileDistributionManagementSnapshotRepository( snapshotRepository ); distributionManagement.setSnapshotRepository( snapshotRepository ); } Site site = distributionManagement.getSite(); if ( site != null ) { visitor.visitProfileDistributionManagementSite( site ); site = visitor.replaceProfileDistributionManagementSite( site ); distributionManagement.setSite( site ); } Relocation relocation = distributionManagement.getRelocation(); if ( relocation != null ) { visitor.visitProfileDistributionManagementRelocation( relocation ); relocation = visitor.replaceProfileDistributionManagementRelocation( relocation ); distributionManagement.setRelocation( relocation ); } }
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c ) throws InvalidRepositoryException { return buildArtifactRepository( repo, artifactRepositoryFactory, c ); }
protected void mergeDeploymentRepository_UniqueVersion( DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context ) { if ( sourceDominant ) { target.setUniqueVersion( source.isUniqueVersion() ); target.setLocation( "uniqueVersion", source.getLocation( "uniqueVersion" ) ); } }
public MavenRepository getMavenReleaseRepo( String repoUrl, boolean isReleaseEnabled, boolean isSnapshotEnabled, InputStream pomStream ) throws Exception { //PlexusContainer container = new DefaultPlexusContainer(); //ArtifactRepositoryFactory artifactRepoFactory = container.lookup(ArtifactRepositoryFactory.class); DeploymentRepository releaseToRepo = new DeploymentRepository(); releaseToRepo.setId("central"); //$NON-NLS-1$ releaseToRepo.setLayout("default"); //$NON-NLS-1$ releaseToRepo.setUrl(repoUrl); RepositoryPolicy pol = new RepositoryPolicy(); pol.setEnabled(isReleaseEnabled); pol.setUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS); pol.setChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE); releaseToRepo.setReleases(pol); RepositoryPolicy pol2 = new RepositoryPolicy(); pol2.setEnabled(isSnapshotEnabled); pol2.setUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS); pol2.setChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE); releaseToRepo.setSnapshots(pol2); MavenProject mavenProject = MavenProjectLoader.parseMavenPom(pomStream); DistributionManagement dm = new DistributionManagement(); dm.setSnapshotRepository(releaseToRepo); mavenProject.setDistributionManagement(dm); //List<ArtifactRepository> remoteArtifactRepositories = new ArrayList<ArtifactRepository>(); //remoteArtifactRepositories.add(releaseToRepo); //mavenProject.setRemoteArtifactRepositories(remoteArtifactRepositories); //org.apache.maven.artifact.repository.Authentication authentication // = new org.apache.maven.artifact.repository.Authentication("user","pw"); //mavenRepo.setAuthentication(authentication); MavenRepository repo = getMavenRepository(mavenProject); return repo; }
@Override public DeploymentRepository replaceDistributionManagementRepository( DeploymentRepository repository ) { return repository; }
@Override public DeploymentRepository replaceDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository ) { return snapshotRepository; }
@Override public DeploymentRepository replaceProfileDistributionManagementRepository( DeploymentRepository repository ) { return repository; }
@Override public DeploymentRepository replaceProfileDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository ) { return snapshotRepository; }
@Override public void visitDistributionManagementRepository( DeploymentRepository repository ) { }
@Override public void visitDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository ) { }
@Override public void visitProfileDistributionManagementRepository( DeploymentRepository repository ) { }
@Override public void visitProfileDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository ) { }
private static DeploymentRepository copyDistributionRepository( DeploymentRepository parentRepository ) { DeploymentRepository repository = new DeploymentRepository(); repository.setId( parentRepository.getId() ); repository.setName( parentRepository.getName() ); repository.setUrl( parentRepository.getUrl() ); repository.setLayout( parentRepository.getLayout() ); repository.setUniqueVersion( parentRepository.isUniqueVersion() ); return repository; }
protected void mergeDeploymentRepository( DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context ) { mergeRepository( target, source, sourceDominant, context ); mergeDeploymentRepository_UniqueVersion( target, source, sourceDominant, context ); }
DeploymentRepository replaceDistributionManagementRepository( DeploymentRepository repository );
DeploymentRepository replaceDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository );
DeploymentRepository replaceProfileDistributionManagementRepository( DeploymentRepository repository );
DeploymentRepository replaceProfileDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository );
void visitDistributionManagementRepository( DeploymentRepository repository );
void visitDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository );
void visitProfileDistributionManagementRepository( DeploymentRepository repository );
void visitProfileDistributionManagementSnapshotRepository( DeploymentRepository snapshotRepository );