Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ProvisioningContext.FOLLOW_ARTIFACT_REPOSITORY_REFERENCES public to avoid duplication #506

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Import-Package: org.bouncycastle.openpgp,
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.p2.core;version="[2.8.0,3.0.0)",
org.eclipse.equinox.p2.core.spi;version="[2.1.0,3.0.0)",
org.eclipse.equinox.p2.engine;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.engine;version="[2.3.0,3.0.0)",
org.eclipse.equinox.p2.engine.query;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.metadata;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.metadata.expression;version="2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ private String escape(String string) {
static private final String PROP_P2_PROFILE = "eclipse.p2.profile"; //$NON-NLS-1$
static private final String NO_ARTIFACT_REPOSITORIES_AVAILABLE = "noArtifactRepositoriesAvailable"; //$NON-NLS-1$

private static final String FOLLOW_ARTIFACT_REPOSITORY_REFERENCES = "org.eclipse.equinox.p2.director.followArtifactRepositoryReferences"; //$NON-NLS-1$
private static final String LIST_GROUPS_SHORTCUT = "Q:GROUP"; //$NON-NLS-1$
private static final String QUERY_SEPARATOR = "Q:"; //$NON-NLS-1$
private static final String QUERY_SEPARATOR_SMALL = "q:"; //$NON-NLS-1$
Expand Down Expand Up @@ -1061,7 +1060,7 @@ private void performProvisioningActions() throws CoreException {
context.setMetadataRepositories(metadataRepositoryLocations.stream().toArray(URI[]::new));
context.setArtifactRepositories(artifactRepositoryLocations.stream().toArray(URI[]::new));
context.setProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES, String.valueOf(followReferences));
context.setProperty(FOLLOW_ARTIFACT_REPOSITORY_REFERENCES, String.valueOf(followReferences));
context.setProperty(ProvisioningContext.FOLLOW_ARTIFACT_REPOSITORY_REFERENCES, String.valueOf(followReferences));

if (addJREIU) {
context.setExtraInstallableUnits(List.of(JREAction.createJREIU()));
Expand Down Expand Up @@ -1516,7 +1515,7 @@ private void revertToPreviousState() throws CoreException {
context.setArtifactRepositories(
artifactRepositoryLocations.toArray(new URI[artifactRepositoryLocations.size()]));
context.setProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES, String.valueOf(followReferences));
context.setProperty(FOLLOW_ARTIFACT_REPOSITORY_REFERENCES, String.valueOf(followReferences));
context.setProperty(ProvisioningContext.FOLLOW_ARTIFACT_REPOSITORY_REFERENCES, String.valueOf(followReferences));
executePlan(context, plan);
}

Expand Down
4 changes: 2 additions & 2 deletions bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Export-Package: org.eclipse.equinox.internal.p2.engine;
org.eclipse.equinox.p2.ui.sdk,
org.eclipse.equinox.p2.ui.sdk.scheduler,
org.eclipse.equinox.p2.touchpoint.eclipse",
org.eclipse.equinox.p2.engine;version="2.2.0",
org.eclipse.equinox.p2.engine;version="2.3.0",
org.eclipse.equinox.p2.engine.query;version="2.0.0",
org.eclipse.equinox.p2.engine.spi;version="2.0.0"
Require-Bundle: org.eclipse.equinox.common,
Expand Down Expand Up @@ -51,7 +51,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.p2.metadata.expression;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.metadata.index;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.query;version="[2.1.0,3.0.0)",
org.eclipse.equinox.p2.repository;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository;version="[2.2.0,3.0.0)",
org.eclipse.equinox.p2.repository.artifact;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.artifact.spi;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.metadata;version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,17 @@ public boolean contains(IArtifactRepository element) {
*/
public static final String CHECK_AUTHORITIES = "org.eclipse.equinox.p2.director.checkAuthorities"; //$NON-NLS-1$

private static final String FOLLOW_ARTIFACT_REPOSITORY_REFERENCES = "org.eclipse.equinox.p2.director.followArtifactRepositoryReferences"; //$NON-NLS-1$
/**
* Instructs the provisioning context to follow artifact repository references
* when providing queryables for obtaining metadata and artifacts. When this
laeubi marked this conversation as resolved.
Show resolved Hide resolved
* property is set to "true", then artifact repository references that are
* encountered while loading the specified artifact repositories will be
* included in the provisioning context.
*
* @see #setArtifactRepositories(URI...)
* @since 2.10
*/
public static final String FOLLOW_ARTIFACT_REPOSITORY_REFERENCES = "org.eclipse.equinox.p2.director.followArtifactRepositoryReferences"; //$NON-NLS-1$

/**
* Creates a new provisioning context that includes all available metadata and
Expand Down Expand Up @@ -275,7 +285,8 @@ private void loadMetadataRepository(IMetadataRepositoryManager manager, URI loca
// If the manager does not know about the repo, consider the reference enablement state
@SuppressWarnings("rawtypes")
private boolean isEnabled(IRepositoryManager manager, IRepositoryReference reference) {
return (manager.contains(reference.getLocation()) && manager.isEnabled(reference.getLocation())) || ((!manager.contains(reference.getLocation())) && ((reference.getOptions() & IRepository.ENABLED) == IRepository.ENABLED));
return (manager.contains(reference.getLocation()) && manager.isEnabled(reference.getLocation()))
|| ((!manager.contains(reference.getLocation())) && reference.isEnabled());
}

private boolean shouldFollowReferences() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.p2.metadata.expression;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.metadata.index;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.query;version="[2.1.0,3.0.0)",
org.eclipse.equinox.p2.repository;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository;version="[2.2.0,3.0.0)",
org.eclipse.equinox.p2.repository.metadata;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.metadata.spi;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.spi;version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public void publishRepositoryReferences() {

List<IRepositoryReference> repositoriesSnapshot = createRepositoriesSnapshot();
for (IRepositoryReference reference : repositoriesSnapshot) {
boolean isEnabled = (reference.getOptions() & IRepository.ENABLED) != 0;
bus.publishEvent(new RepositoryEvent(reference.getLocation(), reference.getType(), RepositoryEvent.DISCOVERED, isEnabled));
bus.publishEvent(new RepositoryEvent(reference.getLocation(), reference.getType(),
RepositoryEvent.DISCOVERED, reference.isEnabled()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Import-Package: org.eclipse.equinox.app;version="[1.0.0,2.0.0)",
org.eclipse.equinox.p2.publisher,
org.eclipse.equinox.p2.publisher.actions,
org.eclipse.equinox.p2.query;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository;version="[2.2.0,3.0.0)",
org.eclipse.equinox.p2.repository.artifact;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.artifact.spi;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.metadata;version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.util.ManifestElement;
Expand Down Expand Up @@ -275,7 +274,7 @@ protected String[] getConfigurationStrings(Collection<IConfigAdvice> configAdvic
if (repo.getNickname() != null) {
parameters.put("name", repo.getNickname()); //$NON-NLS-1$
}
parameters.put("enabled", Boolean.toString((repo.getOptions() & IRepository.ENABLED) == IRepository.ENABLED)); //$NON-NLS-1$
parameters.put("enabled", Boolean.toString(repo.isEnabled())); //$NON-NLS-1$
configurationData += TouchpointInstruction.encodeAction("addRepository", parameters); //$NON-NLS-1$
parameters.remove("enabled"); //$NON-NLS-1$
unconfigurationData += TouchpointInstruction.encodeAction("removeRepository", parameters);//$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.repository;singleton:=true
Bundle-Version: 2.8.200.qualifier
Bundle-Version: 2.9.100.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.repository.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down Expand Up @@ -34,7 +34,7 @@ Export-Package: org.eclipse.equinox.internal.p2.persistence;
org.eclipse.equinox.p2.updatesite,
org.eclipse.pde.core",
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.p2.repository;version="2.1.0",
org.eclipse.equinox.p2.repository;version="2.2.0",
org.eclipse.equinox.p2.repository.artifact;version="2.3.0",
org.eclipse.equinox.p2.repository.artifact.spi;version="2.0.0",
org.eclipse.equinox.p2.repository.metadata;version="2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
* Cloudsmith Inc - public API
Expand Down Expand Up @@ -36,7 +36,7 @@ public interface IRepositoryReference {
int getType();

/**
* Returns bit-wise or of option constants (currently either
* Returns bit-wise or of option constants (currently either
* {@link IRepository#ENABLED} or {@link IRepository#NONE}).
* @return bit-wise or of option constants
*/
Expand All @@ -47,4 +47,15 @@ public interface IRepositoryReference {
* @return The nickname or <code>null</code>
*/
String getNickname();

/**
* Returns whether this reference is enabled or not
*
* @see IRepository#ENABLED
* @return whether this reference is enabled or not
* @since 2.9
*/
default boolean isEnabled() {
return (getOptions() & IRepository.ENABLED) != 0;
}
}
Loading