Skip to content

Commit

Permalink
Forcefully init the OSGi system due to p2 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Jan 30, 2024
1 parent aee4770 commit 636f499
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.net.http.HttpClient.Redirect;
import java.net.http.HttpClient.Version;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpRequest.Builder;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
Expand Down Expand Up @@ -156,7 +157,8 @@ private HttpResponse<InputStream> performGet() throws IOException, InterruptedEx
public Response<Void> head() throws IOException {
try {
HttpResponse<Void> response = client.send(
builder.method("HEAD", null).timeout(Duration.ofSeconds(TIMEOUT_SECONDS)).build(),
builder.method("HEAD", BodyPublishers.noBody()).timeout(Duration.ofSeconds(TIMEOUT_SECONDS))
.build(),
BodyHandlers.discarding());
return new ResponseImplementation<>(response) {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>run-director</id>
<goals>
<goal>director</goal>
</goals>
<phase>package</phase>
<configuration>
<repositories>${target-platform}</repositories>
<installIUs>org.eclipse.osgi</installIUs>
<destination>target/dummy</destination>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.eclipse.tycho.test;

import org.apache.maven.it.Verifier;
import org.junit.Test;

public class P2DirectorPluginTest extends AbstractTychoIntegrationTest {

@Test
public void testJavac() throws Exception {
Verifier verifier = getVerifier("tycho-p2-director-plugin/director-goal-standalone", true, true);
verifier.executeGoal("package");
verifier.verifyErrorFreeLog();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.core.shared.StatusTool;
Expand Down Expand Up @@ -396,6 +397,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
args.addNonNull("-trustedPGPKeys", trustedPGPKeys);
args.addNonNull("-trustedCertificates", trustedCertificates);
try {
//FIXME forcefully init OSGi unless we have a fix for https://github.com/eclipse-equinox/p2/pull/439
agent.getService(IMetadataRepositoryManager.class);
MavenDirectorLog directorLog = new MavenDirectorLog(execution.getExecutionId(), getLog());
Object exitCode = new DirectorApplication(directorLog,
PhaseSetFactory.createDefaultPhaseSetExcluding(new String[] { PhaseSetFactory.PHASE_CHECK_TRUST }),
Expand Down

0 comments on commit 636f499

Please sign in to comment.