-
Notifications
You must be signed in to change notification settings - Fork 2
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
- Loading branch information
Showing
6 changed files
with
113 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.kokuwa.maven.k3s.util; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.apache.maven.plugin.MojoExecutionException; | ||
|
||
/** | ||
* Class to handle markers as communication between mojo executions. | ||
* | ||
* @author [email protected] | ||
* @since 1.3.0 | ||
*/ | ||
public class Marker { | ||
|
||
private final Path startedMarker; | ||
|
||
public Marker(File directory) { | ||
this.startedMarker = directory.toPath().resolve("started"); | ||
} | ||
|
||
public void writeStarted() throws MojoExecutionException { | ||
try { | ||
Files.createDirectories(startedMarker.getParent()); | ||
Files.write(startedMarker, new byte[0]); | ||
} catch (IOException e) { | ||
throw new MojoExecutionException("Failed to write marker to " + startedMarker, e); | ||
} | ||
} | ||
|
||
public boolean consumeStarted() throws MojoExecutionException { | ||
try { | ||
return Files.deleteIfExists(startedMarker); | ||
} catch (IOException e) { | ||
throw new MojoExecutionException("Failed to delete marker at " + startedMarker, e); | ||
} | ||
} | ||
} |
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