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

Add new director mojo #3195

Merged
merged 1 commit into from
Dec 9, 2023
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
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
Loading