Skip to content

Commit

Permalink
When building the old/stable UC files, keep plugins without wiki page…
Browse files Browse the repository at this point in the history
…s for now.

Even if plugin developers update their plugins to include a wiki URL, and make a
new release, this will not apply to older plugin releases.  Because the UC for
LTS releases may only include older plugin releases, and not the latest version
of any given plugin, we should not exclude those plugins because they don't have
a wiki page.

This is a workaround which should ideally be removed once we no longer generate
UC files for LTS 1.596, which was the last LTS in which we tolerated plugins
without a valid wiki URL.
  • Loading branch information
orrc committed Jun 1, 2015
1 parent 66ae4f8 commit 38a695b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
Expand All @@ -24,15 +23,14 @@
* @author Kohsuke Kawaguchi
*/
public class AlphaBetaOnlyRepository extends MavenRepository {
private final MavenRepository base;

/**
* If true, negate the logic and only find non-alpha/beta releases.
*/
private boolean negative;

public AlphaBetaOnlyRepository(MavenRepository base, boolean negative) {
this.base = base;
setBaseRepository(base);
this.negative = negative;
}

Expand Down
31 changes: 27 additions & 4 deletions src/main/java/org/jvnet/hudson/update_center/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ protected MavenRepository createRepository() throws Exception {
protected JSONObject buildPlugins(MavenRepository repository, LatestLinkBuilder latest) throws Exception {
ConfluencePluginList cpl = new ConfluencePluginList();

final boolean isVersionCappedRepository = isVersionCappedRepository(repository);

int validCount = 0;
int deprecatedCount = 0;
int missingWikiUrlCount = 0;
Expand All @@ -275,15 +277,25 @@ protected JSONObject buildPlugins(MavenRepository repository, LatestLinkBuilder
final String givenUrl = plugin.getPomWikiUrl();
final String actualUrl = plugin.getWikiUrl();
if (actualUrl.isEmpty()) {
System.out.println(String.format("=> Excluding %s due to unknown/missing wiki URL: \"%s\"", hpi.artifactId, givenUrl));
missingWikiUrlCount++;
continue;
// When building older Update Centres (e.g. LTS releases), there will be a number of plugins which
// do not have wiki pages, even if the latest versions of those plugins *do* have wiki pages.
// So here we keep the old behaviour: plugins without wiki pages are still kept.
// This behaviour can be removed once we no longer generate UC files for LTS 1.596.x and older
if (isVersionCappedRepository) {
System.out.println(String.format("=> Keeping %s despite unknown/missing wiki URL: \"%s\"", hpi.artifactId, givenUrl));
} else {
System.out.println(String.format("=> Excluding %s due to unknown/missing wiki URL: \"%s\"", hpi.artifactId, givenUrl));
missingWikiUrlCount++;
continue;
}
}
if (!actualUrl.equals(givenUrl)) {
System.out.println(String.format("=> Wiki URL was rewritten from \"%s\" to \"%s\"", givenUrl, actualUrl));
}

System.out.println("=> " + plugin.page.getTitle());
if (plugin.page != null) {
System.out.println("=> " + plugin.page.getTitle());
}
JSONObject json = plugin.toJSON();
System.out.println("=> " + json);
plugins.put(plugin.artifactId, json);
Expand Down Expand Up @@ -472,5 +484,16 @@ protected JSONObject buildCore(MavenRepository repository, LatestLinkBuilder red
return core;
}

/** @return {@code true} iff the given repository, or one of the repositories it wraps, is version-capped. */
private static boolean isVersionCappedRepository(MavenRepository repository) {
if (repository instanceof VersionCappedMavenRepository) {
return true;
}
if (repository.getBaseRepository() == null) {
return false;
}
return isVersionCappedRepository(repository.getBaseRepository());
}

private static final VersionNumber ANY_VERSION = new VersionNumber("999.999");
}
14 changes: 14 additions & 0 deletions src/main/java/org/jvnet/hudson/update_center/MavenRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* @author Kohsuke Kawaguchi
*/
public abstract class MavenRepository {

protected MavenRepository base;

/**
* Discover all plugins from this Maven repository.
*/
Expand Down Expand Up @@ -81,4 +84,15 @@ protected File resolve(ArtifactInfo a) throws AbstractArtifactResolutionExceptio
}

protected abstract File resolve(ArtifactInfo a, String type, String classifier) throws AbstractArtifactResolutionException;

/** Should be called by subclasses who are decorating an existing MavenRepository instance. */
protected void setBaseRepository(MavenRepository base) {
this.base = base;
}

/** @return The base instance that this repository is wrapping; or {@code null} if this is the base instance. */
public MavenRepository getBaseRepository() {
return base;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
* @author Kohsuke Kawaguchi
*/
public class TruncatedMavenRepository extends MavenRepository {
private final MavenRepository base;
private final int cap;

public TruncatedMavenRepository(MavenRepository base, int cap) {
this.base = base;
setBaseRepository(base);
this.cap = cap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* @author Kohsuke Kawaguchi
*/
public class VersionCappedMavenRepository extends MavenRepository {
private final MavenRepository base;

/**
* Version number to cap. We only report plugins that are compatible with this core version.
Expand All @@ -33,7 +32,7 @@ public class VersionCappedMavenRepository extends MavenRepository {
private final VersionNumber capCore;

public VersionCappedMavenRepository(MavenRepository base, VersionNumber capPlugin, VersionNumber capCore) {
this.base = base;
setBaseRepository(base);
this.capPlugin = capPlugin;
this.capCore = capCore;
}
Expand Down

0 comments on commit 38a695b

Please sign in to comment.