-
Notifications
You must be signed in to change notification settings - Fork 21
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
Improve Version Handling in Build & Backend #1043
base: develop
Are you sure you want to change the base?
Changes from all commits
c8b63a7
1f7ffe5
bf22052
747c98f
fb51089
b6f69f8
91242ba
76019d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,55 +96,47 @@ dependencies { | |
} | ||
|
||
|
||
task createVersionPropertiesFile { | ||
doLast { | ||
def aggregatedDataFormatVersion = project.scenariooAggregatedDataFormatVersion | ||
def apiVersion = project.scenariooApiVersion | ||
def documentationVersion = project.documentationVersion | ||
|
||
File versionFile = new File(sourceSets.main.output.classesDirs.getSingleFile().absolutePath + '/version.properties'); | ||
versionFile.write('version=' + versionWithGitCommit + '\n' + | ||
'build-date=' + new Date() + '\n' + | ||
'apiVersion=' + apiVersion + '\n' + | ||
'aggregatedDataFormatVersion=' + aggregatedDataFormatVersion + '\n' + | ||
'documentationVersion=' + documentationVersion + '\n') | ||
/** | ||
* Replace properties in important resource files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think java doc style should only be used on methods. I would use a /* single comment */ style here. |
||
*/ | ||
processResources { | ||
filesMatching(['version.properties', 'banner.txt']) { | ||
expand(project.properties) | ||
} | ||
} | ||
|
||
bootJar { | ||
from('../scenarioo-client/dist') { | ||
into('static') | ||
} | ||
archiveFileName = 'scenarioo-viewer-' + versionWithGitCommit + '.jar' | ||
archiveFileName = 'scenarioo-viewer-' + archiveVersion.get() + '.jar' | ||
} | ||
|
||
bootJar.doLast { | ||
copy { | ||
from('build/libs/') | ||
into('build/libs/') | ||
include('scenarioo-viewer-' + version + '.jar') | ||
rename('scenarioo-viewer-' + version + '.jar', 'scenarioo-latest.jar') | ||
include('scenarioo-viewer-' + archiveVersion.get() + '.jar') | ||
rename('scenarioo-viewer-' + archiveVersion.get() + '.jar', 'scenarioo-latest.jar') | ||
} | ||
} | ||
|
||
bootWar { | ||
from('../scenarioo-client/dist') { | ||
into('WEB-INF/classes/static') | ||
} | ||
archiveFileName = 'scenarioo-viewer-' + versionWithGitCommit + '.war' | ||
archiveFileName = 'scenarioo-viewer-' + archiveVersion.get() + '.war' | ||
} | ||
|
||
bootWar.doLast { | ||
copy { | ||
from('build/libs/') | ||
into('build/libs/') | ||
include('scenarioo-viewer-' + versionWithGitCommit + '.war') | ||
rename('scenarioo-viewer-' + versionWithGitCommit + '.war', 'scenarioo-latest.war') | ||
include('scenarioo-viewer-' + archiveVersion.get() + '.war') | ||
rename('scenarioo-viewer-' + archiveVersion.get() + '.war', 'scenarioo-latest.war') | ||
} | ||
} | ||
|
||
assemble.dependsOn createVersionPropertiesFile | ||
war.dependsOn createVersionPropertiesFile | ||
bootWar.dependsOn ":scenarioo-client:build" | ||
war.dependsOn ":scenarioo-client:build" | ||
|
||
|
@@ -160,7 +152,7 @@ publishing { | |
|
||
groupId 'org.scenarioo' | ||
artifactId 'scenarioo-viewer' | ||
version versionWithGitCommit | ||
version scenariooViewerVersion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the same as archiveVersion, correct? |
||
|
||
pom { | ||
name = 'Scenarioo Viewer' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version=${project.scenariooViewerVersion} | ||
build-date=${project.buildDate} | ||
apiVersion=${project.scenariooApiVersion} | ||
aggregatedDataFormatVersion=${project.scenariooAggregatedDataFormatVersion} | ||
documentationVersion=${project.documentationVersion} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.scenarioo.dao.version; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
public class ApplicationVersionHolderTest { | ||
|
||
@Test | ||
public void initializeFromClassContext_loadsVersionProperlyFromVersionPropertiesFile() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JUnit 5 does not require the public keyword |
||
ApplicationVersionHolder.INSTANCE.initializeFromClassContext(); | ||
assertThat(ApplicationVersionHolder.INSTANCE.getApplicationVersion().getVersion()).isNotBlank(); | ||
assertThat(ApplicationVersionHolder.INSTANCE.getApplicationVersion().getVersion()).isNotEqualToIgnoringCase("unknown"); | ||
assertThat(ApplicationVersionHolder.INSTANCE.getApplicationVersion().getVersion()).describedAs("Version loaded from version.properties is not expected to contain unresolved property expression - Hint: use gradle to build to have proper resolved version.properties").doesNotContain("${"); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Version of the scenarioo viewer web application. | ||
* This version is taken from git version information via `git describe` | ||
* which is a nice version number in case of a properly tagged release version | ||
* or otherwise a version number including the git commit hash for any non-release versions (like developer snapshot releases). | ||
*/ | ||
ext.scenariooViewerVersion = getVersionFromGit() | ||
|
||
/** | ||
* Used Version of Scenarioo Java Library for reading scenarioo docu data | ||
*/ | ||
ext.scenariooApiVersion = '2.1.1' | ||
|
||
/** | ||
* Internal scenarioo format version of produced aggregation data (internal server format version). | ||
* | ||
* On import this version is stored for each build, if the format of a build does not correspond to this format, the | ||
* build is automatically reimported again (all aggregation data recalculated in new format). | ||
* | ||
* First part of the version corresponds to library version that is supported, second part of the version depends on | ||
* internal aggregation format. the second part should be increased whenever something important is changed in the | ||
* internal format or the way that the aggregator is caluclating internal data on builds. | ||
*/ | ||
ext.scenariooAggregatedDataFormatVersion = '2.1.0' | ||
|
||
/** | ||
* Name of the release branch of this scenarioo version, which is used for links to the versioned documentation. | ||
*/ | ||
ext.documentationVersion = '5.0' | ||
|
||
/** | ||
* Build date for version properties file | ||
*/ | ||
ext.buildDate = new Date() | ||
|
||
/** | ||
* Gets the version name from the latest Git tag | ||
* From: http://ryanharter.com/blog/2013/07/30/automatic-versioning-with-git-and-gradle/ | ||
*/ | ||
def getVersionFromGit() { | ||
def stdout = new ByteArrayOutputStream() | ||
exec { | ||
commandLine 'git', 'describe', '--tags' | ||
standardOutput = stdout | ||
} | ||
def version = stdout.toString().trim() | ||
println "Version from git: ${version}" | ||
return version | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?