Skip to content

Commit

Permalink
Skip CHECK_TRUST phase and allow parallel execution of product assembly
Browse files Browse the repository at this point in the history
Currently the DirectorApplication effectively accepts all content but
executing the CHECK_TRUST already takes considerable amount of time,
also each product is assembled one by one even though they operate on
independent output folders and files.

This now skips the CHECK_TRUST phase and adds a new parameter <parallel>
that can be set to enable the parallel execution of assembly and
archiving different product variants.
  • Loading branch information
laeubi committed Jan 26, 2024
1 parent a589986 commit 5b0707d
Show file tree
Hide file tree
Showing 17 changed files with 2,116 additions and 1,884 deletions.
19 changes: 19 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ If you are reading this in the browser, then you can quickly jump to specific ve

## 5.0.0 (under development)

### Support for parallel execution of product assembly / archiving

The mojos `materialize-products` and `archive-products` now support a new `<parallel>` parameter
that enables the parallel assembly / packaging of different product variants.

You can enable this for example like this:

```xml
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<parallel>true</parallel>
</configuration>
</plugin>
```


### new `repo-to-runnable` mojo

This is a replacement for the [Repo2Runnable ant task](https://wiki.eclipse.org/Equinox/p2/Ant_Tasks#Repo2Runnable), example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import java.util.StringJoiner;
import java.util.stream.Collectors;

import org.eclipse.equinox.p2.engine.IPhaseSet;
import org.eclipse.tycho.ArtifactType;
import org.eclipse.tycho.DependencySeed;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.p2.CommandLineArguments;
import org.eclipse.tycho.p2tools.copiedfromp2.PhaseSetFactory;

/**
* Base class for calling a p2 director via command line arguments.
Expand All @@ -42,6 +44,7 @@ public abstract class AbstractDirectorApplicationCommand implements DirectorRunt

private File destination;
private File bundlePool;
private IPhaseSet phaseSet;

@Override
public final void addMetadataSources(Iterable<URI> metadataRepositories) {
Expand Down Expand Up @@ -110,6 +113,18 @@ public void setProfileProperties(Map<String, String> profileProperties) {
this.profileProperties = profileProperties == null ? Map.of() : profileProperties;
}

@Override
public void setPhaseSet(IPhaseSet phaseSet) {
this.phaseSet = phaseSet;
}

public IPhaseSet getPhaseSet() {
if (phaseSet == null) {
return PhaseSetFactory.createDefaultPhaseSet();
}
return phaseSet;
}

/**
* Returns the command line arguments for the p2 director application (not including the
* <code>-application</code> argument).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ public DirectorCommandException(String message) {
super(message);
}

public DirectorCommandException(String message, Throwable cause) {
super(message, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.net.URI;
import java.util.Map;

import org.eclipse.equinox.p2.engine.IPhaseSet;
import org.eclipse.tycho.DependencySeed;
import org.eclipse.tycho.PlatformPropertiesUtils;
import org.eclipse.tycho.TargetEnvironment;
Expand Down Expand Up @@ -53,13 +54,15 @@ public interface Command {
void execute() throws DirectorCommandException;

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

void setPhaseSet(IPhaseSet phaseSet);
}

/**
* Returns a new {@link Command} instance that can be used to execute a command with this
* director runtime.
*/
public Command newInstallCommand();
public Command newInstallCommand(String name);

/**
* Computes the destination of a director install based on a target environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.equinox.internal.p2.director.app.DirectorApplication;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
import org.eclipse.tycho.core.shared.StatusTool;
import org.eclipse.tycho.p2.tools.director.shared.AbstractDirectorApplicationCommand;
import org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException;
import org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime;
import org.eclipse.tycho.p2tools.copiedfromp2.DirectorApplication;
import org.eclipse.tycho.p2tools.copiedfromp2.ILog;

@Component(role = DirectorRuntime.class)
public final class DirectorApplicationWrapper implements DirectorRuntime {
Expand All @@ -32,26 +38,81 @@ public final class DirectorApplicationWrapper implements DirectorRuntime {
@Requirement
Logger logger;

@Requirement
IProvisioningAgentProvider agentProvider;

@Requirement
IProvisioningAgent agent;

@Override
public Command newInstallCommand() {
return new DirectorApplicationWrapperCommand();
public Command newInstallCommand(String name) {
return new DirectorApplicationWrapperCommand(name, agentProvider, agent, logger);
}

private class DirectorApplicationWrapperCommand extends AbstractDirectorApplicationCommand {
private static class DirectorApplicationWrapperCommand extends AbstractDirectorApplicationCommand implements ILog {

private Logger logger;
private String name;
private IProvisioningAgentProvider agentProvider;
private IProvisioningAgent agent;

public DirectorApplicationWrapperCommand(String name, IProvisioningAgentProvider agentProvider,
IProvisioningAgent agent, Logger logger) {
this.name = name;
this.agentProvider = agentProvider;
this.agent = agent;
this.logger = logger;
}

@Override
public void execute() {
List<String> arguments = getDirectorApplicationArguments();
if (logger.isDebugEnabled()) {
logger.debug("Calling director with arguments: " + arguments);
logger.info("Calling director with arguments: " + arguments);
}

Object exitCode = new DirectorApplication().run(arguments.toArray(new String[arguments.size()]));
try {
Object exitCode = new DirectorApplication(this, getPhaseSet(), agent, agentProvider)
.run(arguments.toArray(new String[arguments.size()]));
if (!(EXIT_OK.equals(exitCode))) {
throw new DirectorCommandException("Call to p2 director application failed with exit code "
+ exitCode + ". Program arguments were: " + arguments + ".");
}
} catch (CoreException e) {
throw new DirectorCommandException("Call to p2 director application failed:"
+ StatusTool.collectProblems(e.getStatus()) + ". Program arguments were: " + arguments + ".",
e);
}

}

if (!(EXIT_OK.equals(exitCode))) {
throw new DirectorCommandException("Call to p2 director application failed with exit code " + exitCode
+ ". Program arguments were: " + arguments + ".");
@Override
public void log(IStatus status) {
String message = getMsgLine(StatusTool.toLogMessage(status));
if (status.getSeverity() == IStatus.ERROR) {
logger.error(message, status.getException());
} else if (status.getSeverity() == IStatus.WARNING) {
logger.warn(message);
} else if (status.getSeverity() == IStatus.INFO) {
logger.info(message);
} else {
logger.debug(message);
}

}

@Override
public void printOut(String line) {
logger.info(getMsgLine(line));
}

private String getMsgLine(String line) {
return "[" + name + "] " + line;
}

@Override
public void printErr(String line) {
logger.error(getMsgLine(line));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2023 Christoph Läubrich and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.p2tools;

import org.apache.maven.plugin.logging.Log;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.tycho.core.shared.StatusTool;
import org.eclipse.tycho.p2tools.copiedfromp2.ILog;

public class MavenDirectorLog implements ILog {

private String name;
private Log logger;

public MavenDirectorLog(String name, Log logger) {
this.name = name;
this.logger = logger;
}

@Override
public void log(IStatus status) {
String message = getMsgLine(StatusTool.toLogMessage(status));
if (status.getSeverity() == IStatus.ERROR) {
logger.error(message, status.getException());
} else if (status.getSeverity() == IStatus.WARNING) {
logger.warn(message);
} else if (status.getSeverity() == IStatus.INFO) {
logger.info(message);
} else {
logger.debug(message);
}

}

@Override
public void printOut(String line) {
logger.info(getMsgLine(line));
}

private String getMsgLine(String line) {
return "[" + name + "] " + line;
}

@Override
public void printErr(String line) {
logger.error(getMsgLine(line));
}

}

This file was deleted.

Loading

0 comments on commit 5b0707d

Please sign in to comment.