Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve product assembly #3411

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading