-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Christoph Kuhnke <[email protected]>
- Loading branch information
1 parent
2ccbe00
commit 68c736c
Showing
15 changed files
with
196 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ error-tags: | |
PK-MPC: | ||
packages: | ||
- com.exasol.projectkeeper | ||
highest-index: 63 | ||
highest-index: 64 |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ error-tags: | |
PK-CORE: | ||
packages: | ||
- com.exasol.projectkeeper | ||
highest-index: 170 | ||
highest-index: 179 |
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
80 changes: 80 additions & 0 deletions
80
...r/src/main/java/com/exasol/projectkeeper/sources/analyze/generic/MavenProcessBuilder.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,80 @@ | ||
package com.exasol.projectkeeper.sources.analyze.generic; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.exasol.projectkeeper.OsCheck; | ||
import com.exasol.projectkeeper.OsCheck.OSType; | ||
|
||
/** | ||
* This class allows building and starting a {@code mvn} command. | ||
*/ | ||
public class MavenProcessBuilder { | ||
private final List<String> command = new ArrayList<>(); | ||
private Path workingDir = null; | ||
|
||
private MavenProcessBuilder() { | ||
// Use create() method | ||
} | ||
|
||
/** | ||
* Create a new builder. | ||
* | ||
* @return new builder | ||
*/ | ||
public static MavenProcessBuilder create() { | ||
final MavenProcessBuilder builder = new MavenProcessBuilder(); | ||
builder.addArgument(getMavenExecutable()); | ||
builder.addArgument("--batch-mode"); | ||
return builder; | ||
} | ||
|
||
/** | ||
* Add the given arguments to the command. | ||
* | ||
* @param arguments arguments to add | ||
* @return {@code this} for fluent programming | ||
*/ | ||
public MavenProcessBuilder addArguments(final String... arguments) { | ||
command.addAll(asList(arguments)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Add the given argument to the command. | ||
* | ||
* @param argument argument to add | ||
* @return {@code this} for fluent programming | ||
*/ | ||
public MavenProcessBuilder addArgument(final String argument) { | ||
command.add(argument); | ||
return this; | ||
} | ||
|
||
/** | ||
* Define the working directory where to execute the command. Default: {@code null}. | ||
* | ||
* @param workingDir working dir | ||
* @return {@code this} for fluent programming | ||
*/ | ||
public MavenProcessBuilder workingDir(final Path workingDir) { | ||
this.workingDir = workingDir; | ||
return this; | ||
} | ||
|
||
/** | ||
* Build the command and run it. | ||
* | ||
* @return the running {@link SimpleProcess} | ||
*/ | ||
public SimpleProcess startSimpleProcess() { | ||
return SimpleProcess.start(workingDir, command); | ||
} | ||
|
||
private static String getMavenExecutable() { | ||
return "mvn" + OsCheck.suffix(".cmd"); | ||
} | ||
} |
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
Oops, something went wrong.