-
Notifications
You must be signed in to change notification settings - Fork 267
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
ecc6146
commit bb1bbea
Showing
4 changed files
with
87 additions
and
6 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
1 change: 1 addition & 0 deletions
1
versions-maven-plugin/src/it/it-ci-friendly-versions-001/invoker.properties
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 @@ | ||
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set-version-from-scm-tag |
82 changes: 82 additions & 0 deletions
82
versions-maven-plugin/src/it/it-ci-friendly-versions-001/various.groovy
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,82 @@ | ||
//setup: | ||
|
||
void exec(String command, File outputFile) { | ||
def proc = command.execute(null, basedir) | ||
proc.consumeProcessOutput(outputFile.newOutputStream(), outputFile.newOutputStream()) | ||
proc.waitFor() | ||
assert proc.exitValue() == 0 : "command '${command}' return status: " + proc.exitValue() | ||
} | ||
|
||
def testFile = new File(basedir, 'test.txt') | ||
testFile << 'content' | ||
|
||
exec('git init', new File(basedir, 'setup.log')) | ||
exec('git add test.txt', new File(basedir, 'setup.log')) | ||
exec('git status', new File(basedir, 'setup.log')) | ||
exec('git commit -m first-commit', new File(basedir, 'setup.log')) | ||
exec('git tag first-tag', new File(basedir, 'setup.log')) | ||
|
||
def mavenLogFile = new File(basedir, 'maven.log') | ||
exec('mvn se.lfv.maven.plugins:ci-friendly-versions-maven-plugin:set-version-from-tag', mavenLogFile) | ||
|
||
// verify | ||
|
||
def mavenLogFile = new File(basedir, 'maven.log') | ||
assert mavenLogFile.exists() : "Maven log file does not exist" | ||
|
||
// Read the log file | ||
def logContent = mavenLogFile.text | ||
|
||
// Define a pattern to match the version output | ||
def versionPattern = /\[INFO\] Setting property 'revision' to: (.+)/ | ||
def matcher = (logContent =~ versionPattern) | ||
assert matcher.find() : "Version information not found in log file" | ||
|
||
// Extract the version from the matched group | ||
def actualVersion = matcher[0][1] | ||
|
||
// Define the expected version (for example, based on your tag) | ||
def expectedVersion = '0.0.1-1215-SNAPSHOT' // Replace with the expected version | ||
|
||
assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'" | ||
|
||
// full | ||
|
||
void exec(String command, File outputFile) { | ||
def proc = command.execute(null, basedir) | ||
proc.consumeProcessOutput(outputFile.newOutputStream(), outputFile.newOutputStream()) | ||
proc.waitFor() | ||
assert proc.exitValue() == 0 : "command '${command}' return status: " + proc.exitValue() | ||
} | ||
|
||
// Setup phase | ||
def testFile = new File(basedir, 'test.txt') | ||
testFile << 'content' | ||
|
||
exec('git init', new File(basedir, 'setup.log')) | ||
exec('git add test.txt', new File(basedir, 'setup.log')) | ||
exec('git status', new File(basedir, 'setup.log')) | ||
exec('git commit -m first-commit', new File(basedir, 'setup.log')) | ||
exec('git tag first-tag', new File(basedir, 'setup.log')) | ||
|
||
def mavenLogFile = new File(basedir, 'maven.log') | ||
exec('mvn se.lfv.maven.plugins:ci-friendly-versions-maven-plugin:set-version-from-tag', mavenLogFile) | ||
|
||
// Verification phase | ||
assert mavenLogFile.exists() : "Maven log file does not exist" | ||
|
||
// Read the log file | ||
def logContent = mavenLogFile.text | ||
|
||
// Define a pattern to match the version output (adjust according to your plugin's output format) | ||
def versionPattern = /.*\[INFO\] Setting project version to (.+) from tag.*/ | ||
def matcher = (logContent =~ versionPattern) | ||
assert matcher.find() : "Version information not found in log file" | ||
|
||
// Extract the version from the matched group | ||
def actualVersion = matcher[0][1] | ||
|
||
// Define the expected version (for example, based on your tag) | ||
def expectedVersion = '1.0.0' // Replace with the expected version | ||
|
||
assert actualVersion == expectedVersion : "Expected version '${expectedVersion}', but found '${actualVersion}'" |
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