Skip to content

Commit

Permalink
Add support for including a JRE in the product
Browse files Browse the repository at this point in the history
PDE recently added a new flag for the product to mark it to include a
jre eclipse-pde/eclipse.pde#1075 but this
currently has no effect in Tycho.

This now adds support for automatically include a JustJ JRE if the
option is selected.

Fix #2064
  • Loading branch information
laeubi committed May 5, 2024
1 parent 8ef98a0 commit 66d631c
Show file tree
Hide file tree
Showing 16 changed files with 322 additions and 27 deletions.
10 changes: 10 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ If you are reading this in the browser, then you can quickly jump to specific ve

## 5.0.0 (under development)

### Support for new `includeJRE` flag when building products

PDE recently added a new flag for the product to mark it to [include a JRE](https://github.com/eclipse-pde/eclipse.pde/pull/1075),
this is also now supported with Tycho, activate this flag has the following effects:

- The product gets a new requirement for a JustJ JRE
- The JustJ update site is automatically added to the `materialize-products` goal if such product is present

There is [a demo project](https://github.com/eclipse-tycho/tycho/tree/main/demo/justj/automaticInstall) shows an example for a product using that flag and including an JRE that is suitable to launch the product automatically.

### Support for CycloneDX Maven Plugin

The `tycho-sbom` plugin can be added as a dependency to the [CycloneDX Maven plugin](https://cyclonedx.github.io/cyclonedx-maven-plugin/index.html),
Expand Down
7 changes: 7 additions & 0 deletions demo/justj/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Tycho JustJ Demo Projects
===================

Sample projects demonstrating how to use Tycho with JustJ.

* `product`: Shows how to manually include JustJ in a product using a dedicated feature
* `automaticInstall`: Shows how to use automatic install with the `includeJRE` option in the product
66 changes: 66 additions & 0 deletions demo/justj/automaticInstall/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.tycho.demo</groupId>
<artifactId>product-with-justj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<properties>
<tycho-version>5.0.0-SNAPSHOT</tycho-version>
<target-platform>https://download.eclipse.org/releases/2024-03/</target-platform>
</properties>
<repositories>
<repository>
<id>platform</id>
<url>${target-platform}</url>
<layout>p2</layout>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- as we are only interested in the product in this demo we disable the assemly and archiving of the repository -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>default-assemble-repository</id>
<goals>
<goal>assemble-repository</goal>
</goals>
<phase>none</phase>
</execution>
<execution>
<id>default-archive-repository</id>
<goals>
<goal>archive-repository</goal>
</goals>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
36 changes: 36 additions & 0 deletions demo/justj/automaticInstall/product-with-features.product
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="A product with justj" uid="product-with-justj-features" id="org.eclipse.platform.ide" application="org.eclipse.ui.ide.workbench" version="0.0.1" type="features" includeLaunchers="true" includeJRE="true" autoIncludeRequirements="true">

<configIni>
</configIni>

<launcherArgs>
</launcherArgs>

<launcher>
<win useIco="false">
<bmp/>
</win>
</launcher>

<vm>
</vm>

<plugins>
</plugins>

<features>
<feature id="org.eclipse.platform" installMode="root"/>
</features>

<configurations>
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>

</product>
45 changes: 41 additions & 4 deletions demo/justj/product/pom.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.tycho.demo</groupId>
<artifactId>product-with-justj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<properties>
<tycho-version>2.7.3</tycho-version>
<target-platform>https://download.eclipse.org/releases/2022-06/</target-platform>
<tycho-version>5.0.0-SNAPSHOT</tycho-version>
<target-platform>https://download.eclipse.org/releases/2024-03/</target-platform>
</properties>
<repositories>
<repository>
Expand All @@ -35,11 +36,47 @@
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<!-- Prevents Tycho from injecting some mock a.jre units for system packages and EE capabilities;
<!-- Prevents Tycho from injecting some mock a.jre units for
system packages and EE capabilities;
while we expect justj units to provide them -->
<executionEnvironment>none</executionEnvironment>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- as we are only interested in the product in this demo we disable the assemly and archiving of the repository -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>default-assemble-repository</id>
<goals>
<goal>assemble-repository</goal>
</goals>
<phase>none</phase>
</execution>
<execution>
<id>default-archive-repository</id>
<goals>
<goal>archive-repository</goal>
</goals>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
20 changes: 19 additions & 1 deletion demo/justj/product/product-with-features.product
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="A product with justj" uid="product-with-justj-features" version="0.0.1" useFeatures="true" includeLaunchers="true">
<product name="A product with justj" uid="product-with-justj-features" version="0.0.1" type="features" includeLaunchers="true" autoIncludeRequirements="true">

<configIni use="default">
</configIni>
Expand All @@ -11,12 +11,30 @@
</vmArgsMac>
</launcherArgs>

<launcher>
<win useIco="false">
<bmp/>
</win>
</launcher>

<vm>
</vm>

<plugins>
</plugins>

<features>
<feature id="org.eclipse.justj.openjdk.hotspot.jre.full"/>
<feature id="org.eclipse.platform" installMode="root"/>
</features>

<configurations>
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>


</product>
4 changes: 4 additions & 0 deletions tycho-api/src/main/java/org/eclipse/tycho/TychoConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public interface TychoConstants {

public static final String TYCHO_NOT_CONFIGURED = "Tycho build extension not configured for ";

public static final String NAMESPACE_JUSTJ = "org.eclipse.justj";

public static final String NAME_JUSTJ_JRE = "jre";

static final String ANY_QUALIFIER = "qualifier";

static final boolean USE_SMART_BUILDER = Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@
import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.publisher.AdviceFileAdvice;
import org.eclipse.equinox.p2.publisher.IPublisherAction;
import org.eclipse.equinox.p2.publisher.IPublisherAdvice;
import org.eclipse.equinox.p2.publisher.actions.RootIUAction;
import org.eclipse.equinox.p2.publisher.eclipse.ProductAction;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
Expand All @@ -36,6 +41,7 @@
import org.eclipse.tycho.BuildFailureException;
import org.eclipse.tycho.DependencySeed;
import org.eclipse.tycho.Interpolator;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.core.resolver.target.ArtifactTypeHelper;
import org.eclipse.tycho.core.shared.MavenLogger;
import org.eclipse.tycho.p2.repository.PublishingRepository;
Expand Down Expand Up @@ -68,7 +74,7 @@ public PublishProductToolImpl(PublisherActionRunner publisherRunner, PublishingR
}

@Override
public List<DependencySeed> publishProduct(File productFile, File launcherBinaries, String flavor)
public List<DependencySeed> publishProduct(File productFile, File launcherBinaries, String flavor, String jreName)
throws IllegalArgumentException {

IProductDescriptor originalProduct = loadProductFile(productFile);
Expand All @@ -77,7 +83,25 @@ public List<DependencySeed> publishProduct(File productFile, File launcherBinari

IPublisherAdvice[] advice = getProductSpecificAdviceFileAdvice(productFile, expandedProduct);

ProductAction action = new ProductAction(null, expandedProduct, flavor, launcherBinaries);
ProductAction action = new ProductAction(null, expandedProduct, flavor, launcherBinaries) {
@Override
protected IPublisherAction createRootIUAction() {
if (jreName != null) {
return new RootIUAction(id, version, name) {
@Override
protected Collection<IRequirement> createIURequirements(
Collection<? extends IVersionedId> children) {
Collection<IRequirement> requirements = new ArrayList<>(
super.createIURequirements(children));
requirements.add(MetadataFactory.createRequirement(TychoConstants.NAMESPACE_JUSTJ, jreName,
null, null, false, false));
return requirements;
}
};
}
return super.createRootIUAction();
}
};
IMetadataRepository metadataRepository = publishingRepository.getMetadataRepository();
IArtifactRepository artifactRepository = publishingRepository
.getArtifactRepositoryForWriting(new ProductBinariesWriteSession(expandedProduct.getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public interface PublishProductTool {
* A folder that contains the native Eclipse launcher binaries
* @param flavor
* The installation flavor the product shall be published for
* @param jreName
* name of the JustJ JRE to include or <code>null</code> if none is desired
* @return a handles to the published product IU
*/
List<DependencySeed> publishProduct(File productDefinition, File launcherBinaries, String flavor);
List<DependencySeed> publishProduct(File productDefinition, File launcherBinaries, String flavor, String jreName);
}
Loading

0 comments on commit 66d631c

Please sign in to comment.