Skip to content

Commit

Permalink
Prepare Tycho for upcomming p2 source requirements changes
Browse files Browse the repository at this point in the history
(cherry picked from commit 3e31ab9)
  • Loading branch information
laeubi committed Feb 5, 2024
1 parent c73de78 commit c7397f0
Show file tree
Hide file tree
Showing 37 changed files with 120 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* <p>
* Over {@link IArtifactProvider}, this interface adds a method for obtaining the artifacts as files
* in the local file system. (With the <tt>IArtifactProvider</tt> interface, artifacts can only be
* in the local file system. (With the <code>IArtifactProvider</code> interface, artifacts can only be
* obtained as stream.)
* </p>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*
* <p>
* Over {@link IArtifactFileProvider}, this interface adds methods for obtaining artifacts in raw
* formats. (With the <tt>IArtifactFileProvider</tt> interface, artifacts can only be obtained in
* formats. (With the <code>IArtifactFileProvider</code> interface, artifacts can only be obtained in
* the canonical format, i.e. the format in which the artifact can be used directly without
* additional decompression.)
* </p>
* <p>
* Over {@link IRawArtifactProvider}, this interface adds a method for obtaining the artifacts as
* files in the local file system. (With the <tt>IRawArtifactProvider</tt> interface, artifacts can
* files in the local file system. (With the <code>IRawArtifactProvider</code> interface, artifacts can
* only be obtained as stream.)
* </p>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* <p>
* Over {@link IArtifactProvider}, this interface adds methods for obtaining artifacts in raw
* formats. (With the <tt>IArtifactProvider</tt> interface, artifacts can only be obtained in the
* formats. (With the <code>IArtifactProvider</code> interface, artifacts can only be obtained in the
* canonical format, i.e. the format in which the artifact can be used directly without additional
* decompression.)
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ArtifactKey resolveArtifact(String type, String id, String versionRef)
* Returns the file system location of the given target platform artifact.
*
* @return the location of the given artifact, or <code>null</code> if the artifact does not
* exist in the target platform, or if the given <tt>ArtifactKey</tt> refers to an
* exist in the target platform, or if the given <code>ArtifactKey</code> refers to an
* metadata-only "artifact" e.g. a product definition.
*/
File getArtifactLocation(ArtifactKey artifact);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
private String executable;

/**
* If <tt>only</tt> is specified, the annotation processors will run but no compilation will be
* performed. If <tt>none</tt> is specified, annotation processors will not be discovered or
* If <code>only</code> is specified, the annotation processors will run but no compilation will be
* performed. If <code>none</code> is specified, annotation processors will not be discovered or
* run; compilation will proceed as if no annotation processors were found. By default the
* compiler must search the classpath for annotation processors, so specifying <tt>none</tt> may
* compiler must search the classpath for annotation processors, so specifying <code>none</code> may
* speed compilation if annotation processing is not required. This parameter requires a 1.6 VM
* or above and is used only if the compliance is 1.6
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo impl
* </pre>
*
* The default value of the bootclasspath used for compilation is
* <tt>&lt;jdkHome&gt;/lib/*;&lt;jdkHome&gt;/lib/ext/*;&lt;jdkHome&gt;/lib/endorsed/*</tt> .
* <code>&lt;jdkHome&gt;/lib/*;&lt;jdkHome&gt;/lib/ext/*;&lt;jdkHome&gt;/lib/endorsed/*</code> .
*
* For JDKs with different filesystem layouts, the bootclasspath can be specified explicitly in
* the configuration section.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.eclipse.tycho.core.osgitools.OsgiManifest;
import org.eclipse.tycho.core.osgitools.OsgiManifestParserException;
import org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader;
import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode;
import org.eclipse.tycho.helper.PluginRealmHelper;
import org.eclipse.tycho.model.project.EclipseProject;
import org.eclipse.tycho.targetplatform.TargetDefinition;
Expand Down Expand Up @@ -162,6 +163,10 @@ private Map<String, String> getProfileProperties(TargetEnvironment environment,
TargetPlatformConfiguration configuration) {
Map<String, String> properties = environment.toFilterProperties();
properties.put("org.eclipse.update.install.features", "true");
IncludeSourceMode sourceMode = configuration.getTargetDefinitionIncludeSourceMode();
if (sourceMode == IncludeSourceMode.force || sourceMode == IncludeSourceMode.honor) {
properties.put("org.eclipse.update.install.sources", "true");
}
properties.putAll(configuration.getProfileProperties());
return properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
* Thrown if a custom execution environment name does not comply to format
* <tt>&lt;name&gt;-&lt;version&gt;</tt>, with name not containing dashes (-) and version being a
* <code>&lt;name&gt;-&lt;version&gt;</code>, with name not containing dashes (-) and version being a
* valid OSGi version.
*/
public class InvalidEENameException extends RuntimeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private void setBREEHeaderSelectionPolicy(TargetPlatformConfiguration result, Xp
/**
* Take the constraints of the configured execution environment into account when resolving
* dependencies or target definitions. These constraints include the list of system packages and
* the <tt>Bundle-RequiredExecutionEnvironment</tt> header. When set to <code>true</code>, the
* the <code>Bundle-RequiredExecutionEnvironment</code> header. When set to <code>true</code>, the
* dependency resolution verifies that the bundle and all required bundles can be used in an
* OSGi container with the configured execution environment.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* repository.
*
* <p>
* Note that a <tt>MirroringArtifactProvider</tt> is not a transparent cache of the remote
* Note that a <code>MirroringArtifactProvider</code> is not a transparent cache of the remote
* providers. The content provided by this instance differs from the remote providers' content in
* the following ways:
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* A p2 artifact repository implementation for the build output directory. Instances are persisted
* in the following files:
* <ul>
* <li>A <tt>p2artifacts.xml</tt> file in the given build target directory, which contains a list of
* <li>A <code>p2artifacts.xml</code> file in the given build target directory, which contains a list of
* all artifacts with p2 <i>and</i> Maven coordinates. (In particular the classifier part of the
* Maven coordinates is relevant.) This file is deployed to Maven repositories alongside with the
* built Tycho artifact.</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import org.eclipse.tycho.p2.repository.MetadataIO;

/**
* A p2 metadata repository implementation which is persisted in a <tt>p2content.xml</tt>. The
* <tt>p2content.xml</tt> is the file that is deployed to Maven repositories alongside with the
* A p2 metadata repository implementation which is persisted in a <code>p2content.xml</code>. The
* <code>p2content.xml</code> is the file that is deployed to Maven repositories alongside with the
* built Tycho artifact.
*
* @see TychoConstants#FILE_NAME_P2_METADATA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class ArtifactSinkFactory {
* The key of the artifact to be written.
* @param destination
* The output stream to write the artifact content to. The ownership of the stream is
* not transferred, i.e. neither this method nor the returned <tt>IArtifactSink</tt>
* not transferred, i.e. neither this method nor the returned <code>IArtifactSink</code>
* will call {@link OutputStream#close()} on the stream.
*/
public static IArtifactSink writeToStream(IArtifactKey artifactKey, OutputStream destination) {
Expand All @@ -55,7 +55,7 @@ public static IArtifactSink writeToStream(IArtifactKey artifactKey, OutputStream
* An {@link IArtifactDescriptor} specifying artifact and format to be written.
* @param destination
* The output stream to write the raw content to. The ownership of the stream is not
* transferred, i.e. neither this method nor the returned <tt>IRawArtifactSink</tt>
* transferred, i.e. neither this method nor the returned <code>IRawArtifactSink</code>
* will call {@link OutputStream#close()} on the stream.
*/
public static IRawArtifactSink rawWriteToStream(IArtifactDescriptor artifactDescriptor, OutputStream destination) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import java.io.File;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.TreeMap;
import java.util.stream.Collectors;

import org.eclipse.equinox.p2.engine.IPhaseSet;
Expand Down Expand Up @@ -45,6 +45,7 @@ public abstract class AbstractDirectorApplicationCommand implements DirectorRunt
private File destination;
private File bundlePool;
private IPhaseSet phaseSet;
private boolean installSources;

@Override
public final void addMetadataSources(Iterable<URI> metadataRepositories) {
Expand Down Expand Up @@ -93,6 +94,11 @@ public final void setInstallFeatures(boolean installFeatures) {
this.installFeatures = installFeatures;
}

@Override
public void setInstallSources(boolean installSources) {
this.installSources = installSources;
}

@Override
public final void setVerifyOnly(boolean verifyOnly) {
this.verifyOnly = verifyOnly;
Expand Down Expand Up @@ -136,8 +142,7 @@ protected List<String> getDirectorApplicationArguments() {
args.addUnlessEmpty("-installIU", unitsToInstall);
args.add("-destination", destination.getAbsolutePath());
args.add("-profile", profileName);
Map<String, String> props = new HashMap<>(this.profileProperties);
props.put("org.eclipse.update.install.features", Boolean.toString(installFeatures));
Map<String, String> props = getProfileProperties();
args.add("-profileProperties", props.entrySet().stream().map(entry -> entry.getKey() + '=' + entry.getValue())
.collect(Collectors.joining(",")));
args.add("-roaming");
Expand All @@ -153,8 +158,17 @@ protected List<String> getDirectorApplicationArguments() {
args.add("-p2.ws", environment.getWs());
args.add("-p2.arch", environment.getArch());
}

return args.asList();
}

@Override
public Map<String, String> getProfileProperties() {
Map<String, String> props = new TreeMap<>(this.profileProperties);
props.put("org.eclipse.update.install.features", Boolean.toString(installFeatures));
if (installSources && props.get("org.eclipse.update.install.sources") == null) {
props.put("org.eclipse.update.install.sources", "true");
}
return props;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ public interface Command {

void setProfileProperties(Map<String, String> profileProperties);

/**
* @return a copy of the effective profile properties
*/
Map<String, String> getProfileProperties();

void setPhaseSet(IPhaseSet phaseSet);

void setInstallSources(boolean installSources);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public List<IVersionedId> getFeatures() {
public List<IVersionedId> getFeatures(int options) {
if (options == INCLUDED_FEATURES) {
return expandedFeatures;
} else {
// currently not needed by the publisher action -> omitted for simplicity
throw new UnsupportedOperationException();
} else if (options == IProductDescriptor.ROOT_FEATURES) {
return Collections.unmodifiableList(expandedRootFeatures);
}
return List.of();
}

public List<IInstallableUnit> getRootFeatures() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected abstract Collection<IInstallableUnit> resolve(Map<String, String> prop
private Map<String, String> getEffectiveFilterProperties(TargetEnvironment environment) {
Map<String, String> result = environment.toFilterProperties();
result.put("org.eclipse.update.install.features", "true");
result.put("org.eclipse.update.install.sources", "true");
insertAdditionalFilterProperties(result);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
* <p>
* The javadoc executable path is determined in this order:
* <ul>
* <li><tt>executable</tt> argument of the <tt>javadocOptions</tt> configuration
* <li><code>executable</code> argument of the <code>javadocOptions</code> configuration
* element, if available</li>
* <li>active Maven toolchain</li>
* <li><tt>java.home</tt> system property</li>
* <li><tt>JAVA_HOME</tt> environment setting</li>
* <li><code>java.home</code> system property</li>
* <li><code>JAVA_HOME</code> environment setting</li>
* <li>if none of the above can be used, the javadoc executable is invoked
* without an explicit path and relies on the operating system PATH
* variable</li>
Expand Down Expand Up @@ -116,19 +116,19 @@ public class JavadocMojo extends AbstractMojo {
* Options for calling the javadoc application. Possible options are (all
* options are optional):
* <ul>
* <li><tt>ignoreError</tt>, specifies if errors calling javadoc should be
* <li><code>ignoreError</code>, specifies if errors calling javadoc should be
* ignored</li>
* <li><tt>doclet</tt>, used as javadoc <tt>-doclet</tt> parameter</li>
* <li><tt>docletArtifacts</tt>, dependencies will be resovled and added as
* <tt>-docletpath</tt> parameter</li>
* <li><tt>encoding</tt>, used as javadoc <tt>-encoding</tt> parameter (default:
* <tt>${project.build.sourceEncoding}</tt></li>
* <li><tt>additionalArguments</tt>, a list of additional arguments passed to
* <li><code>doclet</code>, used as javadoc <code>-doclet</code> parameter</li>
* <li><code>docletArtifacts</code>, dependencies will be resovled and added as
* <code>-docletpath</code> parameter</li>
* <li><code>encoding</code>, used as javadoc <code>-encoding</code> parameter (default:
* <code>${project.build.sourceEncoding}</code></li>
* <li><code>additionalArguments</code>, a list of additional arguments passed to
* javadoc</li>
* <li><tt>includes</tt>/<tt>excludes</tt>, the list of names of packages to be
* included in or excluded from JavaDoc processing; use '<tt>*</tt>' character
* <li><code>includes</code>/<code>excludes</code>, the list of names of packages to be
* included in or excluded from JavaDoc processing; use '<code>*</code>' character
* as wildcard</li>
* <li><tt>executable</tt>, the javadoc executable path to be used (see mojo
* <li><code>executable</code>, the javadoc executable path to be used (see mojo
* description for the default path calculation)</li>
* </ul>
* Example configuration:
Expand Down Expand Up @@ -168,9 +168,9 @@ public class JavadocMojo extends AbstractMojo {
/**
* Options for creating the toc files.
* <ul>
* <li><tt>mainLabel</tt>, specifies the main label of the toc file (default:
* <li><code>mainLabel</code>, specifies the main label of the toc file (default:
* "API Reference")</li>
* <li><tt>mainFilename</tt>, specifies the filename of the TOC file (default:
* <li><code>mainFilename</code>, specifies the filename of the TOC file (default:
* "overview-summary.html")
* </ul>
* Example configuration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class AbstractProductMojo extends AbstractMojo {
* <p>
* If the project contains more than one product file, you need to choose for which ones you
* want to create distribution archives. If you choose to install more than one product, you
* need to specify the <tt>attachId</tt> (which becomes a part of the classifier) to make the
* need to specify the <code>attachId</code> (which becomes a part of the classifier) to make the
* classifiers unique. Example:
*
* <pre>
Expand Down Expand Up @@ -98,11 +98,11 @@ abstract class AbstractProductMojo extends AbstractMojo {
*
* Details on the product-specific configuration parameters:
* <ul>
* <li><tt>rootFolder</tt> - The path where the installed product shall be stored in the
* <li><code>rootFolder</code> - The path where the installed product shall be stored in the
* archive, e.g. "eclipse". By default, the product is stored in the archive root.</li>
* <li><tt>rootFolders</tt> - OS-specific installation root folders, overriding
* <tt>rootFolder</tt>. Allowed children are <tt>&lt;macosx&gt;</tt>, <tt>&lt;win32&gt;</tt>,
* <tt>&lt;linux&gt;</tt> and <tt>&lt;freebsd&gt;</tt> or any other OS supported by p2. Since
* <li><code>rootFolders</code> - OS-specific installation root folders, overriding
* <code>rootFolder</code>. Allowed children are <code>&lt;macosx&gt;</code>, <code>&lt;win32&gt;</code>,
* <code>&lt;linux&gt;</code> and <code>&lt;freebsd&gt;</code> or any other OS supported by p2. Since
* 0.18.0</li>
* </ul>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public class DirectorMojo extends AbstractMojo {

/**
* A list of properties in the form key=value pairs. Effective only when a new profile is
* created. For example <tt>org.eclipse.update.install.features=true</tt> to install the
* created. For example <code>org.eclipse.update.install.features=true</code> to install the
* features into the product.
*/
@Parameter(property = "profileproperties")
Expand All @@ -227,6 +227,9 @@ public class DirectorMojo extends AbstractMojo {
@Parameter(property = "installFeatures", defaultValue = "true")
private boolean installFeatures;

@Parameter(defaultValue = "false")
private boolean installSources;

/**
* Additional profile properties to set when materializing the product
*/
Expand Down Expand Up @@ -473,6 +476,9 @@ private Map<String, String> getPropertyMap(String csvPropertiesMap, Map<String,
if (installFeatures) {
map.put("org.eclipse.update.install.features", "true");
}
if (installSources) {
map.put("org.eclipse.update.install.sources", "true");
}
return map;
}

Expand Down
Loading

0 comments on commit c7397f0

Please sign in to comment.