Skip to content

Commit

Permalink
Fixes #3610 - Add ability to set temporary directory for Piranha Uber (
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Jan 9, 2024
1 parent 947d40a commit 1861314
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions uber/src/main/java/cloud/piranha/uber/UberPiranha.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,54 @@

package cloud.piranha.uber;

import java.io.File;

/**
* The uber version of Piranha.
* The Uber version of Piranha.
*
* @author Manfred Riem ([email protected])
*/
public class UberPiranha {
public class UberPiranha implements Runnable {

/**
* Stores the temporary directory.
*/
private File tempDirectory = new File(".piranhaUber");

/**
* Main method.
*
* @param arguments the command-line arguments.
*/
public static void main(String[] arguments) {
UberPiranha piranha = new UberPiranha();
piranha.parseArguments(arguments);
piranha.run();
}

/**
* Parse the arguments.
*
* @param arguments the arguments.
*/
private void parseArguments(String[] arguments) {
for(int i=0; i<arguments.length; i++) {
if (arguments[i].equals("--uber-temp-directory")) {
tempDirectory = new File(arguments[i + 1]);
}
}
}

/**
* Run method.
*/
@Override
public void run() {
if (!tempDirectory.exists()) {
if (!tempDirectory.mkdirs()) {
System.err.println("Unable to create temporary directory, exiting");
System.exit(1);
}
}
}
}

0 comments on commit 1861314

Please sign in to comment.