generated from Best-Quality-Engineering/ossrh-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redefine NextRevisionMojo as ReleaseVersionMojo
- Loading branch information
1 parent
e585a6d
commit 7eea90f
Showing
12 changed files
with
341 additions
and
323 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
73 changes: 73 additions & 0 deletions
73
src/main/java/tools/bestquality/maven/ci/ExportVersionMojo.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,73 @@ | ||
package tools.bestquality.maven.ci; | ||
|
||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.apache.maven.project.MavenProject; | ||
import tools.bestquality.io.Content; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
|
||
import static java.lang.String.format; | ||
import static java.lang.System.out; | ||
import static java.nio.file.Files.createDirectories; | ||
import static tools.bestquality.maven.ci.CiVersion.versionFrom; | ||
|
||
public abstract class ExportVersionMojo<M extends ExportVersionMojo<M>> | ||
extends CiMojo { | ||
protected final Content content; | ||
|
||
@Parameter(defaultValue = "${project}", readonly = true, required = true) | ||
protected MavenProject project; | ||
|
||
@Parameter(defaultValue = "${project.build.directory}/ci") | ||
protected File outputDirectory; | ||
|
||
@Parameter(alias = "scriptable", property = "scriptable", defaultValue = "false") | ||
protected boolean scriptable; | ||
|
||
public ExportVersionMojo(Content content) { | ||
this.content = content; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public M withProject(MavenProject project) { | ||
this.project = project; | ||
return (M) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public M withOutputDirectory(File outputDirectory) { | ||
this.outputDirectory = outputDirectory; | ||
return (M) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public M withScriptable(boolean forceStdout) { | ||
this.scriptable = forceStdout; | ||
return (M) this; | ||
} | ||
|
||
protected CiVersion current() { | ||
return versionFrom(project.getProperties()); | ||
} | ||
|
||
protected void exportVersion(String filename, String version) | ||
throws MojoExecutionException { | ||
if (scriptable) { | ||
out.print(version); | ||
out.flush(); | ||
} else { | ||
Path directory = outputDirectory.toPath(); | ||
Path file = directory.resolve(filename); | ||
info(format("Exporting version to %s", file.toAbsolutePath())); | ||
try { | ||
createDirectories(directory); | ||
content.write(file, version); | ||
} catch (Exception e) { | ||
error(format("Failure exporting version to: %s", file.toAbsolutePath()), e); | ||
throw new MojoExecutionException(e.getLocalizedMessage(), 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
110 changes: 0 additions & 110 deletions
110
src/main/java/tools/bestquality/maven/ci/IncrementingMojo.java
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
src/main/java/tools/bestquality/maven/ci/NextRevisionMojo.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.