-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a markdown builder to simplify common tasks and unify generation
- Loading branch information
Showing
6 changed files
with
93 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,8 @@ public int getMarkers() { | |
return markers; | ||
} | ||
|
||
public boolean isEmpty() { | ||
return fixed.isEmpty(); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
tycho-core/src/main/java/org/eclipse/tycho/core/MarkdownBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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.core; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.maven.plugin.MojoFailureException; | ||
|
||
public class MarkdownBuilder { | ||
|
||
private final List<String> lines = new ArrayList<>(); | ||
private Path output; | ||
|
||
public MarkdownBuilder(File output) { | ||
this(output == null ? (Path) null : output.toPath()); | ||
} | ||
|
||
public MarkdownBuilder(Path output) { | ||
this.output = output; | ||
} | ||
|
||
public MarkdownBuilder add(String string) { | ||
lines.add(string); | ||
return this; | ||
} | ||
|
||
public MarkdownBuilder addListItem(String item) { | ||
lines.add("- " + item); | ||
return this; | ||
} | ||
|
||
public void write() throws MojoFailureException { | ||
if (output == null) { | ||
return; | ||
} | ||
try { | ||
Files.createDirectories(output.getParent()); | ||
Files.writeString(output, lines.stream().collect(Collectors.joining(System.lineSeparator()))); | ||
} catch (IOException e) { | ||
throw new MojoFailureException(e); | ||
} | ||
} | ||
|
||
} |