Skip to content

Commit

Permalink
Add new director mojo
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Dec 9, 2023
1 parent bd0beeb commit bfabab9
Show file tree
Hide file tree
Showing 5 changed files with 549 additions and 23 deletions.
28 changes: 28 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,34 @@ If you are reading this in the browser, then you can quickly jump to specific ve

## 5.0.0 (under development)

### new `director` mojo

This mojo can be used in two ways:

1. As a commandline invocation passing arguments as properties using `mvn org.eclipse.tycho:tycho-p2-director-plugin:director -Ddestination=[target] ... -D...`
2. as an execution inside a pom

```xml
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<goals>
<goal>director</goal>
</goals>
<phase>package</phase>
<configuration>
<destination>...</destination>
... other arguments ...
</configuration>
</execution>
</executions>
</plugin>
```


### new `tycho-eclipse-plugin`

Tycho now contains a new `tycho-eclipse-plugin` that is dedicated to executing "tasks like eclipse", this currently includes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*******************************************************************************
* Copyright (c) 2012, 2014 SAP SE 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:
* SAP SE - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.p2;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.stream.Collectors;

public class CommandLineArguments {
List<String> arguments = new ArrayList<>();

public void add(String flag) {
arguments.add(flag);
}

public void add(String parameterName, String parameterValue) {
arguments.add(parameterName);
arguments.add(parameterValue);
}

public void addNonNull(String parameterName, String parameterValue) {
if (parameterValue != null) {
arguments.add(parameterName);
arguments.add(parameterValue);
}
}

public void addUnlessEmpty(String parameterName, StringJoiner parameterValue) {
if (parameterValue.length() > 0) {
add(parameterName, parameterValue.toString());
}
}

public void addNotEmpty(String parameterName, List<String> list, CharSequence seperator) {
if (list.isEmpty()) {
return;
}
add(parameterName, list.stream().collect(Collectors.joining(seperator)));
}

public void addNotEmpty(String parameterName, Map<String, String> propertyMap, CharSequence keyValueSeparator,
CharSequence seperator) {
if (propertyMap.isEmpty()) {
return;
}
add(parameterName,
propertyMap.entrySet().stream().map(entry -> entry.getKey() + keyValueSeparator + entry.getValue())
.collect(Collectors.joining(seperator)));
}

public void addFlagIfTrue(String flag, boolean value) {
if (value) {
add(flag);
}
}

public void addNonNull(String parameterName, File file) {
if (file != null) {
add(parameterName, file.getAbsolutePath());
}
}

public List<String> asList() {
return new ArrayList<>(arguments);
}

public String[] toArray() {
return arguments.toArray(String[]::new);
}

@Override
public String toString() {
return arguments.stream().collect(Collectors.joining(" "));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -24,6 +23,7 @@
import org.eclipse.tycho.ArtifactType;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.core.resolver.shared.DependencySeed;
import org.eclipse.tycho.p2.CommandLineArguments;

/**
* Base class for calling a p2 director via command line arguments.
Expand Down Expand Up @@ -142,26 +142,4 @@ protected List<String> getDirectorApplicationArguments() {
return args.asList();
}

private static class CommandLineArguments {
List<String> arguments = new ArrayList<>();

void add(String flag) {
arguments.add(flag);
}

void add(String parameterName, String parameterValue) {
arguments.add(parameterName);
arguments.add(parameterValue);
}

void addUnlessEmpty(String parameterName, StringJoiner parameterValue) {
if (parameterValue.length() > 0) {
add(parameterName, parameterValue.toString());
}
}

public List<String> asList() {
return new ArrayList<>(arguments);
}
}
}
5 changes: 5 additions & 0 deletions tycho-p2-director-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
<artifactId>tycho-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Loading

0 comments on commit bfabab9

Please sign in to comment.