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.
- Loading branch information
1 parent
519dc6c
commit 3a63722
Showing
25 changed files
with
626 additions
and
186 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/tools/bestquality/maven/ci/CiMojoConfigurator.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,18 @@ | ||
package tools.bestquality.maven.ci; | ||
|
||
import org.codehaus.plexus.component.configurator.BasicComponentConfigurator; | ||
import tools.bestquality.maven.versioning.IncrementorConverter; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.inject.Named; | ||
|
||
@Named("ci-mojo-configurator") | ||
public class CiMojoConfigurator | ||
extends BasicComponentConfigurator { | ||
|
||
@PostConstruct | ||
public void initialize() { | ||
converterLookup.registerConverter(new IncrementorConverter()); | ||
converterLookup.registerConverter(new CiVersionSourceConverter()); | ||
} | ||
} |
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
48 changes: 5 additions & 43 deletions
48
src/main/java/tools/bestquality/maven/ci/CiVersionSource.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 |
---|---|---|
@@ -1,49 +1,11 @@ | ||
package tools.bestquality.maven.ci; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
import static java.lang.String.format; | ||
import static java.util.Arrays.stream; | ||
import static tools.bestquality.maven.ci.CiVersion.versionFrom; | ||
|
||
enum CiVersionSource { | ||
PROJECT() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) { | ||
return versionFrom(project.getProperties()); | ||
} | ||
}, | ||
SYSTEM() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) { | ||
return versionFrom(session.getSystemProperties()); | ||
} | ||
}, | ||
MERGE_SYSTEM_FIRST() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) { | ||
return versionFrom(session.getSystemProperties()) | ||
.withMissingFrom(project.getProperties()); | ||
} | ||
}, | ||
MERGE_PROJECT_FIRST() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) { | ||
return versionFrom(project.getProperties()) | ||
.withMissingFrom(session.getSystemProperties()); | ||
} | ||
}; | ||
|
||
public abstract CiVersion from(MavenProject project, MavenSession session); | ||
|
||
public static CiVersionSource source(String name) { | ||
return stream(values()) | ||
.filter(item -> item.name() | ||
.equalsIgnoreCase(name.replace("-", "_"))) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException( | ||
format("No enum constant in %s matching %s", | ||
CiVersionSource.class.getCanonicalName(), name))); | ||
} | ||
@FunctionalInterface | ||
public interface CiVersionSource { | ||
CiVersion from(MavenProject project, MavenSession session) | ||
throws MojoFailureException; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/tools/bestquality/maven/ci/CiVersionSourceConverter.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,21 @@ | ||
package tools.bestquality.maven.ci; | ||
|
||
import org.codehaus.plexus.component.configurator.ComponentConfigurationException; | ||
import org.codehaus.plexus.component.configurator.converters.basic.AbstractBasicConverter; | ||
|
||
import static tools.bestquality.maven.ci.CiVersionSources.source; | ||
|
||
public class CiVersionSourceConverter | ||
extends AbstractBasicConverter { | ||
|
||
@Override | ||
public boolean canConvert(Class<?> type) { | ||
return CiVersionSource.class.equals(type); | ||
} | ||
|
||
@Override | ||
protected Object fromString(String value) | ||
throws ComponentConfigurationException { | ||
return source(value); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/tools/bestquality/maven/ci/CiVersionSources.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,56 @@ | ||
package tools.bestquality.maven.ci; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
import static java.lang.String.format; | ||
import static java.util.Arrays.stream; | ||
import static tools.bestquality.maven.ci.CiVersion.versionFrom; | ||
|
||
enum CiVersionSources | ||
implements CiVersionSource { | ||
PROJECT() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) | ||
throws MojoFailureException { | ||
return versionFrom(project.getProperties()); | ||
} | ||
}, | ||
SYSTEM() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) | ||
throws MojoFailureException { | ||
return versionFrom(session.getSystemProperties()); | ||
} | ||
}, | ||
MERGE_SYSTEM_FIRST() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) | ||
throws MojoFailureException { | ||
return versionFrom(session.getSystemProperties()) | ||
.withMissingFrom(project.getProperties()); | ||
} | ||
}, | ||
MERGE_PROJECT_FIRST() { | ||
@Override | ||
public CiVersion from(MavenProject project, MavenSession session) | ||
throws MojoFailureException { | ||
return versionFrom(project.getProperties()) | ||
.withMissingFrom(session.getSystemProperties()); | ||
} | ||
}; | ||
|
||
public abstract CiVersion from(MavenProject project, MavenSession session) | ||
throws MojoFailureException; | ||
|
||
public static CiVersionSource source(String name) { | ||
return stream(values()) | ||
.filter(item -> item.name() | ||
.equalsIgnoreCase(name.replace("-", "_"))) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException( | ||
format("No enum constant in %s matching %s", | ||
CiVersionSources.class.getCanonicalName(), name))); | ||
} | ||
} |
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
Oops, something went wrong.