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 63d1ea2 commit e86d5e6
Show file tree
Hide file tree
Showing 5 changed files with 522 additions and 23 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This page describes the noteworthy improvements provided by each release of Ecli

### backports:

- new director mojo
- support for PDE Api Tools Annotations
- api tools fixes
- new `tycho-eclipse-plugin`
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 e86d5e6

Please sign in to comment.