private void writeRepositoryPolicy(RepositoryPolicy repositoryPolicy, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (repositoryPolicy.getEnabled() != null) { writeValue(serializer, "enabled", repositoryPolicy.getEnabled(), repositoryPolicy); } if (repositoryPolicy.getUpdatePolicy() != null) { writeValue(serializer, "updatePolicy", repositoryPolicy.getUpdatePolicy(), repositoryPolicy); } if (repositoryPolicy.getChecksumPolicy() != null) { writeValue(serializer, "checksumPolicy", repositoryPolicy.getChecksumPolicy(), repositoryPolicy); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(repositoryPolicy, "", start, b.length()); }
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 visitPluginRepository( ModelVisitor visitor, Repository repository ) { RepositoryPolicy releases = repository.getReleases(); if ( releases != null ) { visitor.visitPluginRepositoryRelease( releases ); releases = visitor.replacePluginRepositoryRelease( releases ); repository.setReleases( releases ); } RepositoryPolicy snapshots = repository.getSnapshots(); if ( snapshots != null ) { visitor.visitPluginRepositorySnapshot( snapshots ); snapshots = visitor.replacePluginRepositorySnapshot( snapshots ); repository.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 void visitProfilePluginRepository( ModelVisitor visitor, Repository repository ) { RepositoryPolicy releases = repository.getReleases(); if ( releases != null ) { visitor.visitProfilePluginRepositoryRelease( releases ); releases = visitor.replaceProfilePluginRepositoryRelease( releases ); repository.setReleases( releases ); } RepositoryPolicy snapshots = repository.getSnapshots(); if ( snapshots != null ) { visitor.visitProfilePluginRepositorySnapshot( snapshots ); snapshots = visitor.replaceProfilePluginRepositorySnapshot( snapshots ); repository.setSnapshots( snapshots ); } }
private void visitProfileRepository( ModelVisitor visitor, Repository repository ) { RepositoryPolicy releases = repository.getReleases(); if ( releases != null ) { visitor.visitProfileRepositoryRelease( releases ); releases = visitor.replaceProfileRepositoryRelease( releases ); repository.setReleases( releases ); } RepositoryPolicy snapshots = repository.getSnapshots(); if ( snapshots != null ) { visitor.visitProfileRepositorySnapshot( snapshots ); snapshots = visitor.replaceProfileRepositorySnapshot( snapshots ); repository.setSnapshots( snapshots ); } }
private void visitRepository( ModelVisitor visitor, Repository repository ) { RepositoryPolicy releases = repository.getReleases(); if ( releases != null ) { visitor.visitRepositoryRelease( releases ); releases = visitor.replaceRepositoryRelease( releases ); repository.setReleases( releases ); } RepositoryPolicy snapshots = repository.getSnapshots(); if ( snapshots != null ) { visitor.visitRepositorySnapshot( snapshots ); snapshots = visitor.replaceRepositorySnapshot( snapshots ); repository.setSnapshots( snapshots ); } }
/** * This method determines if the given {@link Repository} section is identical to what is defined from the super * POM. * * @param repo is the {@link Repository} section to check. * @return <code>true</code> if maven central default configuration, <code>false</code> otherwise. */ private static boolean isCentralRepositoryFromSuperPom( Repository repo ) { if ( repo != null ) { if ( "central".equals( repo.getId() ) ) { RepositoryPolicy snapshots = repo.getSnapshots(); if ( snapshots != null && !snapshots.isEnabled() ) { return true; } } } return false; }
public ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy ) { boolean enabled = true; String updatePolicy = null; String checksumPolicy = null; if ( policy != null ) { enabled = policy.isEnabled(); if ( policy.getUpdatePolicy() != null ) { updatePolicy = policy.getUpdatePolicy(); } if ( policy.getChecksumPolicy() != null ) { checksumPolicy = policy.getChecksumPolicy(); } } return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
protected List<ArtifactRepository> getRemoteRepositories() throws Exception { File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); RepositoryPolicy policy = new RepositoryPolicy(); policy.setEnabled( true ); policy.setChecksumPolicy( "ignore" ); policy.setUpdatePolicy( "always" ); Repository repository = new Repository(); repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID ); repository.setUrl( "file://" + repoDir.toURI().getPath() ); repository.setReleases( policy ); repository.setSnapshots( policy ); return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ); }
protected List<ArtifactRepository> getRemoteRepositories() throws InvalidRepositoryException { File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); RepositoryPolicy policy = new RepositoryPolicy(); policy.setEnabled( true ); policy.setChecksumPolicy( "ignore" ); policy.setUpdatePolicy( "always" ); Repository repository = new Repository(); repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID ); repository.setUrl( "file://" + repoDir.toURI().getPath() ); repository.setReleases( policy ); repository.setSnapshots( policy ); return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ); }
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 writeRepository(Repository repository, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (repository.getReleases() != null) { writeRepositoryPolicy((RepositoryPolicy) repository.getReleases(), "releases", serializer); } if (repository.getSnapshots() != null) { writeRepositoryPolicy((RepositoryPolicy) repository.getSnapshots(), "snapshots", serializer); } if (repository.getId() != null) { writeValue(serializer, "id", repository.getId(), repository); } if (repository.getName() != null) { writeValue(serializer, "name", repository.getName(), repository); } if (repository.getUrl() != null) { writeValue(serializer, "url", repository.getUrl(), repository); } if ((repository.getLayout() != null) && !repository.getLayout().equals("default")) { writeValue(serializer, "layout", repository.getLayout(), repository); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(repository, "", start, b.length()); }
/** * Method updateRepositoryPolicy * * @param value * @param element * @param counter * @param xmlTag */ protected void updateRepositoryPolicy( RepositoryPolicy 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, "enabled", value.isEnabled() ? null : String.valueOf( value.isEnabled() ), "true" ); findAndReplaceSimpleElement( innerCount, root, "updatePolicy", value.getUpdatePolicy(), null ); findAndReplaceSimpleElement( innerCount, root, "checksumPolicy", value.getChecksumPolicy(), null ); } }
private static MavenRepositoryPolicy convertPolicy(RepositoryPolicy policy) { if (policy != null) { return new MavenRepositoryPolicy( policy.isEnabled(), policy.getUpdatePolicy(), policy.getChecksumPolicy()); } return null; }
private static RepositoryPolicy convertToMavenPolicy(MavenRepositoryPolicy policy) { RepositoryPolicy result = new RepositoryPolicy(); result.setChecksumPolicy(policy.getChecksumPolicy()); result.setEnabled(policy.isEnabled()); result.setUpdatePolicy(policy.getUpdatePolicy()); return result; }
protected Repository getGlobalRepositoryFromPreference() { String repoURL = preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", GLOBAL_REPOSITORY_URL, null, null); if (repoURL != null) { Repository repo = new Repository(); repo.setUrl(repoURL); repo.setId(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", GLOBAL_REPOSITORY_ID, null, null)); RepositoryPolicy releasePolicy = new RepositoryPolicy(); String releaseEnabled = preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", RELEASES_ENABLED, null, null); releasePolicy.setEnabled(releaseEnabled != null); releasePolicy.setUpdatePolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", RELEASES_UPDATE_POLICY, null, null)); releasePolicy.setChecksumPolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", RELEASES_CHECKSUM_POLICY, null, null)); repo.setReleases(releasePolicy); RepositoryPolicy snapshotPolicy = new RepositoryPolicy(); String snapshotsEnabled = preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", SNAPSHOTS_ENABLED, null, null); snapshotPolicy.setEnabled(snapshotsEnabled != null); snapshotPolicy.setUpdatePolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", SNAPSHOTS_UPDATE_POLICY, null, null)); snapshotPolicy.setChecksumPolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui", SNAPSHOTS_CHECKSUM_POLICY, null, null)); repo.setSnapshots(snapshotPolicy); return repo; } return null; }
protected void mergeRepositoryPolicy( RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context ) { mergeRepositoryPolicy_Enabled( target, source, sourceDominant, context ); mergeRepositoryPolicy_UpdatePolicy( target, source, sourceDominant, context ); mergeRepositoryPolicy_ChecksumPolicy( target, source, sourceDominant, context ); }
protected void mergeRepositoryPolicy_Enabled( RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getEnabled(); if ( src != null ) { if ( sourceDominant || target.getEnabled() == null ) { target.setEnabled( src ); target.setLocation( "enabled", source.getLocation( "enabled" ) ); } } }
protected void mergeRepositoryPolicy_UpdatePolicy( RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUpdatePolicy(); if ( src != null ) { if ( sourceDominant || target.getUpdatePolicy() == null ) { target.setUpdatePolicy( src ); target.setLocation( "updatePolicy", source.getLocation( "updatePolicy" ) ); } } }
protected void mergeRepositoryPolicy_ChecksumPolicy( RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getChecksumPolicy(); if ( src != null ) { if ( sourceDominant || target.getChecksumPolicy() == null ) { target.setChecksumPolicy( src ); target.setLocation( "checksumPolicy", source.getLocation( "checksumPolicy" ) ); } } }
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 RepositoryPolicy replaceDistributionManagementRepositoryRelease( RepositoryPolicy releases ) { return releases; }
@Override public RepositoryPolicy replaceDistributionManagementRepositorySnapshot( RepositoryPolicy snapshots ) { return snapshots; }
@Override public RepositoryPolicy replaceDistributionManagementSnapshotRepositoryRelease( RepositoryPolicy releases ) { return releases; }
@Override public RepositoryPolicy replaceDistributionManagementSnapshotRepositorySnapshot( RepositoryPolicy snapshots ) { return snapshots; }
@Override public RepositoryPolicy replacePluginRepositoryRelease( RepositoryPolicy releases ) { return releases; }
@Override public RepositoryPolicy replacePluginRepositorySnapshot( RepositoryPolicy snapshots ) { return snapshots; }
@Override public RepositoryPolicy replaceProfileDistributionManagementRepositoryRelease( RepositoryPolicy releases ) { return releases; }
@Override public RepositoryPolicy replaceProfileDistributionManagementRepositorySnapshot( RepositoryPolicy snapshots ) { return snapshots; }
@Override public RepositoryPolicy replaceProfileDistributionManagementSnapshotRepositoryRelease( RepositoryPolicy releases ) { return releases; }
@Override public RepositoryPolicy replaceProfileDistributionManagementSnapshotRepositorySnapshot( RepositoryPolicy snapshots ) { return snapshots; }
@Override public RepositoryPolicy replaceProfilePluginRepositoryRelease( RepositoryPolicy releases ) { return releases; }
@Override public RepositoryPolicy replaceProfilePluginRepositorySnapshot( RepositoryPolicy snapshots ) { return snapshots; }
@Override public RepositoryPolicy replaceProfileRepositoryRelease( RepositoryPolicy releases ) { return releases; }
@Override public RepositoryPolicy replaceProfileRepositorySnapshot( RepositoryPolicy snapshots ) { return snapshots; }
@Override public RepositoryPolicy replaceRepositoryRelease( RepositoryPolicy releases ) { return releases; }