-
-
Notifications
You must be signed in to change notification settings - Fork 75
Default values for configuration, especially VersionInfo #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lukaszlenart
merged 35 commits into
orphan-oss:master
from
koksyn:feature-default-params
Jan 6, 2023
Merged
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
1a18ba8
Fix: Escape angle brackets in Markdown documentation to be printed out.
koksyn 1db37ca
`disableVersionInfoDefaults` docs note added
koksyn ab175c3
Snapshot version bump according to default parameters changes
koksyn 6ab798f
New parameter for disabling VersionInfo defaults
koksyn e7df172
Filling out VersionInfo defaults
koksyn d616519
Filling out VersionInfo defaults
koksyn 6cb5594
Unit tests for Copyright generator
koksyn 54be52f
Copyright generator description
koksyn c53a795
JUnitParams lib added to POM.xml
koksyn 3a06542
Unit tests for Launch4j fileVersion generator
koksyn 8930ec0
Additional Unit tests for Launch4j fileVersion generator
koksyn 15abdd3
Refactoring of Launch4j fileVersion generator
koksyn 0217cca
"errTitle" default value provided
koksyn e2976d0
"errTitle" default value in docs
koksyn 0d2c995
"versionInfo -> originalFilename" default value added
koksyn 234974f
release version notes Resolves #98
koksyn e6c5d21
Line added to MOJO doc
koksyn e9ffe5f
trademarks & companyName also filled by defaults
koksyn b38f942
Mockito Core library added
koksyn b1ede4d
VersionInfo refactoring
koksyn 4b7a245
VersionInfo unit tests
koksyn f41b870
Adds missing VersionInfo unit tests
koksyn c489157
Adds missing Mojo param to MojoTest
koksyn 65cafe9
Refactoring MojoTest
koksyn d34d506
Missing dependency added to POM
koksyn 63673e5
Possibility of not filling out VersionInfo in XML at all
koksyn 8764598
Documentation for VersionInfo defaults added
koksyn a8e4209
Merge branch 'orphan-oss:master' into feature-default-params
koksyn b66d97e
Throwing exception datailed descriptions
koksyn 1f64567
Merge remote-tracking branch 'origin/feature-default-params' into fea…
koksyn d019663
Release version without snapshot
koksyn 98b1c65
Revert "Release version without snapshot"
koksyn ba82667
default scope for filling out defaults inside VersionInfo
koksyn 79337bd
Newline's at the end of the files
koksyn e7f2bb8
Private constructors for utility classes added
koksyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/akathist/maven/plugins/launch4j/generators/CopyrightGenerator.java
This file contains hidden or 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,37 @@ | ||
| package com.akathist.maven.plugins.launch4j.generators; | ||
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.maven.model.Organization; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| public class CopyrightGenerator { | ||
| /** | ||
| * Parameters should be taken from MavenProject properties: | ||
| * @param projectInceptionYear as ${project.inceptionYear} | ||
| * @param projectOrganization as ${project.organization} | ||
| */ | ||
| public static String generate(String projectInceptionYear, Organization projectOrganization) { | ||
| String inceptionYear = generateInceptionYear(projectInceptionYear); | ||
| int buildYear = LocalDate.now().getYear(); | ||
| String organizationName = generateOrganizationName(projectOrganization); | ||
|
|
||
| return String.format("Copyright © %s%d%s. All rights reserved.", inceptionYear, buildYear, organizationName); | ||
| } | ||
|
|
||
| private static String generateInceptionYear(String projectInceptionYear) { | ||
| if(StringUtils.isNotBlank(projectInceptionYear)) { | ||
| return projectInceptionYear + "-"; | ||
| } | ||
|
|
||
| return ""; | ||
| } | ||
|
|
||
| private static String generateOrganizationName(Organization projectOrganization) { | ||
| if(projectOrganization != null && StringUtils.isNotBlank(projectOrganization.getName())) { | ||
| return " " + projectOrganization.getName(); | ||
| } | ||
|
|
||
| return ""; | ||
| } | ||
| } | ||
koksyn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
69 changes: 69 additions & 0 deletions
69
...ain/java/com/akathist/maven/plugins/launch4j/generators/Launch4jFileVersionGenerator.java
This file contains hidden or 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,69 @@ | ||
| package com.akathist.maven.plugins.launch4j.generators; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| public class Launch4jFileVersionGenerator { | ||
koksyn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private static final int REQUIRED_NESTED_VERSION_LEVELS = 4; | ||
| private static final String SIMPLE_PROJECT_VERSION_REGEX = "^((\\d(\\.)?)*\\d+)(-\\w+)?$"; | ||
| private static final Pattern simpleProjectVersionPattern = Pattern.compile( | ||
| SIMPLE_PROJECT_VERSION_REGEX, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | ||
| ); | ||
lukaszlenart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Converts projectVersion into a format "x.x.x.x" ('x' as a number), which is required by Launch4j. | ||
| * | ||
| * For shorter versions like "x.x.x" it will append zeros (to the 4th level) at the end like "x.x.x.0". | ||
| * Every text flag like "-SNAPSHOT" or "-alpha" will be cut off. | ||
| * Too many nested numbers (more than 4 levels) will be cut off as well: "1.2.3.4.5.6" -> "1.2.3.4". | ||
| * | ||
| * Param should be taken from MavenProject property: | ||
| * @param projectVersion as ${project.version} | ||
lukaszlenart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| public static String generate(String projectVersion) { | ||
| if(projectVersion == null) { | ||
| return null; | ||
| } | ||
| if(!simpleProjectVersionPattern.matcher(projectVersion).matches()) { | ||
| throw new IllegalArgumentException("'project.version' is in invalid format. Regex pattern: " + SIMPLE_PROJECT_VERSION_REGEX); | ||
| } | ||
|
|
||
| String versionLevels = removeTextFlags(projectVersion); | ||
| String limitedVersionLevels = cutOffTooManyNestedLevels(versionLevels); | ||
|
|
||
| return appendMissingNestedLevelsByZeros(limitedVersionLevels); | ||
| } | ||
|
|
||
| private static String removeTextFlags(String version) { | ||
| if(version.contains("-")) { | ||
| String[] parts = version.split("-"); | ||
| return parts[0]; | ||
| } | ||
|
|
||
| return version; | ||
| } | ||
|
|
||
| private static String cutOffTooManyNestedLevels(String versionLevels) { | ||
| String[] levels = versionLevels.split("\\."); | ||
|
|
||
| if(levels.length > REQUIRED_NESTED_VERSION_LEVELS) { | ||
| List<String> limitedLevels = Arrays.asList(levels) | ||
| .subList(0, REQUIRED_NESTED_VERSION_LEVELS); | ||
| return String.join(".", limitedLevels); | ||
| } | ||
|
|
||
| return versionLevels; | ||
| } | ||
|
|
||
| private static String appendMissingNestedLevelsByZeros(String versionLevels) { | ||
| String[] levels = versionLevels.split("\\."); | ||
|
|
||
| StringBuilder filledLevels = new StringBuilder(versionLevels); | ||
| for (int i = levels.length; i < REQUIRED_NESTED_VERSION_LEVELS; i++) { | ||
| filledLevels.append(".0"); | ||
| } | ||
|
|
||
| return filledLevels.toString(); | ||
| } | ||
| } | ||
koksyn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.