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.
  • Loading branch information
laeubi committed May 5, 2024
1 parent 8ef98a0 commit 0bf01e0
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 5 deletions.
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>
31 changes: 31 additions & 0 deletions demo/justj/automaticInstall/product-with-features.product
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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 use="default">
</configIni>

<launcherArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
</launcherArgs>

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

<vm>
</vm>

<plugins>
</plugins>

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


</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>
11 changes: 10 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,6 +11,15 @@
</vmArgsMac>
</launcherArgs>

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

<vm>
</vm>

<plugins>
</plugins>

Expand Down
9 changes: 9 additions & 0 deletions tycho-its/src/test/java/org/eclipse/tycho/test/DemoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.tycho.test;

import java.io.File;
import java.util.List;

import org.apache.maven.it.Verifier;
Expand All @@ -23,6 +24,14 @@
*/
public class DemoTest extends AbstractTychoIntegrationTest {

@Test
public void testTychoJustJDemo() throws Exception {
assertIncludesJustJ(new File(runDemo("justj", "-f", "product").getBasedir(),
"product/target/products/product-with-justj-features"));
assertIncludesJustJ(new File(runDemo("justj", "-f", "automaticInstall").getBasedir(),
"automaticInstall/target/products/product-with-justj-features"));
}

@Test
public void testSureFireDemo() throws Exception {
runDemo("testing/surefire/", "-f", "with-maven-layout");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -293,4 +295,17 @@ protected static void verifyErrorFreeLog(Verifier verifier) throws VerificationE
}
}

protected void assertIncludesJustJ(File productDir) throws IOException {
File eclipseIni = assertFileExists(productDir, "**/eclipse.ini")[0];
List<String> lines = Files.readAllLines(eclipseIni.toPath());
for (int i = 0; i < lines.size(); i++) {
if (lines.get(i).equals("-vm")) {
String vm = lines.get(i + 1);
assertTrue("VM (" + vm + ") is not JustJ!", vm.startsWith("plugins/org.eclipse.justj.openjdk."));
return;
}
}
fail("No VM installed in the product!");
}

}

0 comments on commit 0bf01e0

Please sign in to comment.