Bug 562908 - Populate the JustJ Git clones with initial content
Allow a release with only a qualifier change.
diff --git a/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/P2Manager.java b/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/P2Manager.java
index 12c5ee8..bb7a371 100644
--- a/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/P2Manager.java
+++ b/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/P2Manager.java
@@ -180,9 +180,15 @@
Path milestoneLatest = updateSiteGenerator.getCompositeUpdateSiteDestination("milestone", true);
Path source = updateSiteGenerator.getLatest(milestoneLatest);
ensureSourceMilestoneExists(source);
- String version = updateSiteGenerator.getVersion(source);
+ String version = updateSiteGenerator.getVersion(source, false);
Path target = updateSiteGenerator.getPromoteUpdateSiteDestination("release", version);
- Assert.isTrue(!Files.exists(target), "The release '" + target + "' already exists");
+ Path primaryTarget = target;
+ if (Files.exists(target))
+ {
+ version = updateSiteGenerator.getVersion(source, true);
+ target = updateSiteGenerator.getPromoteUpdateSiteDestination("release", version);
+ Assert.isTrue(!Files.exists(target), "The release '" + target + "' already exists and so does '" + primaryTarget + "'");
+ }
updateSiteGenerator.mirrorUpdateSite(source, target, "release");
Path milestone = updateSiteGenerator.getCompositeUpdateSiteDestination("milestone", false);
diff --git a/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/UpdateSiteGenerator.java b/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/UpdateSiteGenerator.java
index d58557f..147d847 100644
--- a/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/UpdateSiteGenerator.java
+++ b/plugins/org.eclipse.justj.p2/src/org/eclipse/justj/p2/UpdateSiteGenerator.java
@@ -462,16 +462,17 @@
/**
* Returns the version of the {@code org.eclipse.emf.sdk.feature.group} installable unit in the target repository.
* @param targetRepository the repository location.
+ * @param qualified whether to include the qualifier in the version.
* @return the associated semantic version of the repository.
* @throws Exception
*/
- public String getVersion(Path targetRepository) throws Exception
+ public String getVersion(Path targetRepository, boolean qualified) throws Exception
{
RepositoryAnalyzer repositoryAnalyzer = new RepositoryAnalyzer();
RepositoryDescriptor repositoryDescriptor = new RepositoryDescriptor();
repositoryDescriptor.setLocation(createURI(targetRepository));
repositoryAnalyzer.addSource(repositoryDescriptor);
- String version = repositoryAnalyzer.getVersion(versionIU);
+ String version = repositoryAnalyzer.getVersion(versionIU, qualified);
return version;
}
@@ -1163,11 +1164,12 @@
* Returns the three-segment version of the largest version of the IU with the prefix as its ID in the repository.
*
* @param prefix the prefix used to filter down the IUs to consider, or {@code null} to consider all IUs.
+ * @param qualified whether to include the qualifier in the version.
* @return the three-segment version of the largest version of the IU with the prefix as its ID in the repository.
*
* @throws ProvisionException
*/
- public String getVersion(String prefix) throws ProvisionException
+ public String getVersion(String prefix, boolean qualified) throws ProvisionException
{
IMetadataRepository repository = getCompositeMetadataRepository();
IQueryResult<IInstallableUnit> query = repository.query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
@@ -1189,7 +1191,7 @@
}
}
- return maxVersion.getMajor() + "." + maxVersion.getMinor() + "." + maxVersion.getMicro();
+ return maxVersion.getMajor() + "." + maxVersion.getMinor() + "." + maxVersion.getMicro() + (qualified ? "." + maxVersion.getQualifier() : "");
}
/**