Conversation
… build is triggered by a tag.
… string which is potentially injected by bash script.
Codecov Report
@@ Coverage Diff @@
## master #228 +/- ##
===========================================
+ Coverage 93.12% 93.2% +0.07%
+ Complexity 805 802 -3
===========================================
Files 68 68
Lines 2080 2075 -5
Branches 120 118 -2
===========================================
- Hits 1937 1934 -3
Misses 122 122
+ Partials 21 19 -2
Continue to review full report at Codecov.
|
|
|
||
| **Bug Fixes** (1) | ||
| - **Commons** - Fixed library version in User-Agent headers of JVM SDK clients using the library. Now it's fetched | ||
| from the JAR manifest but injected from set-solutioninfo-version.sh [#227](https://github.com/commercetools/commercetools-sync-java/issues/227) |
There was a problem hiding this comment.
Or i don't understand the real issue, of the solution is an overhead in the library....
But even if you decided to replace tokens, why do you implement custom shell scripts, instead of using default gradle plugins for replacements?
https://www.google.de/search?q=gradle+replace+plugin
https://stackoverflow.com/a/30038751/907576 (the answer from known Opal guy :) )
|
@andrii-kovalenko-ct Is there another advantage to having it as a gradle script as opposed to bash script, other than for consistently having all scripts in one place/language? If so, then we should also better change this gradle as well (https://github.com/commercetools/commercetools-sync-java/blob/master/travis-publish.sh) right? |
…fail build to catch failty releases.
| jdk: | ||
| - openjdk8 | ||
| install: true # skips travis' default installation step which executes gradle assemble. | ||
| before_script: ./gradlew injectVersion |
There was a problem hiding this comment.
Why inject and not just setReleaseVersion?
| apply from: "$rootDir/gradle-scripts/javadocs-publish.gradle" | ||
| apply from: "$rootDir/gradle-scripts/execution-order.gradle" No newline at end of file | ||
| apply from: "$rootDir/gradle-scripts/execution-order.gradle" | ||
| apply from: "$rootDir/gradle-scripts/version-setter.gradle" No newline at end of file |
There was a problem hiding this comment.
Also here: set-release-version.gradle
| if (!versionFileContents.contains(versionPlaceholder)) { | ||
| throw new InvalidUserCodeException("$versionFile does not contain the placeholder: $versionPlaceholder. " + | ||
| "Please make sure the file contains the placeholder, in order for the version to be injected " + | ||
| "correctly.") |
Isn't it enough as an advantage? Then also:
Nice point! I've been dreaming to re-factor this wasp nest since my first days in the company, but never had enough time. Also, as a best approach - we could try to create our own travis publish gradle plugin. A good topic for the next hackaton :) |
| - openjdk8 | ||
| install: true # skips travis' default installation step which executes gradle assemble. | ||
| before_script: ./set-solutioninfo-version.sh | ||
| before_script: ./gradlew injectVersion |
There was a problem hiding this comment.
why not make it as a part of build tasks graph (e.g. using dependsOn, must/shouldRunAfter, finalizedBy and so on).
There was a problem hiding this comment.
Because I only want the release version to be replaced only on travis, but not locally on every dev's machine when they run the build locally.
There was a problem hiding this comment.
then i'd recommend to create a custom gradle task (for example, ciBuild) and run it from travis (here instead of clean build, avoiding before_script block
This approach makes build script independent from CI tool (e.g. you don't depend on Travis's native before_script)
There was a problem hiding this comment.
It is already a custom gradle task. I made it inline now: 62bddb4, but also applies to the after_success then, no?
There was a problem hiding this comment.
but also applies to the after_success
good point!
(but don't over-engineer: estimate is it easy to re-factor now all those scripts, or maybe make a dedicated task for this)
| "correctly.") | ||
| } | ||
|
|
||
| if (isPr.equals("false") && tagName) { |
There was a problem hiding this comment.
use groove goodness :) :
isPr == "false"http://mrhaki.blogspot.de/2009/09/groovy-goodness-check-for-object.html
There was a problem hiding this comment.
168c067, I don't think I need the PR check at all actually.
|
|
||
| if (libVersion) { | ||
| println "Injecting the version: '$libVersion' in $versionFile" | ||
| ant.replace(file: versionFile, token: versionPlaceholder, value: libVersion) |
There was a problem hiding this comment.
because, as I understand, it is used within the filter function when files are being copied. Whereas in this case I just want to replace in file, rather then replace while copying.
@andrii-kovalenko-ct It is definitely enough :) but I just wanted to know the advantages. Thanks for explicitly stating them. Also great idea with creating our own gradle script! I created an issue about it: #229 |
|
by default tasks order in gradle build is undefined, so it might be that |
|
@andrii-kovalenko-ct ah, I didn't know that it also doesn't ensure order when running explicitly from CLI: FYI, Take a look at this tho: https://discuss.gradle.org/t/ordering-tasks-on-the-command-line-versus-using-mustrunafter/12017
But still defining explicit ordering is better than relying on CLI input. dc27248 Thanks for pointing it out. |
|
hm, i was sure command line order doesn't influence the order at all.... |
Summary
Addresses mainly #227.
Instead of depending on JAR manifest for fetching library version and name. Which could be removed by the users of the library, especially in the case when packing it as a dependency in a fat jar, it's quite common that the lib's manifest is replaced with the original applications' manifest.
Therefore, the SolutionInfo version is now injected by a bash script (which potentially takes the version from the tag name, if the build was caused by a tag)
More details
The template string
#{LIB_VERSION}in the SyncSolutionInfo.java is replaced in the bash script here.This
sedreplace command makes a backup of the original file after replacement, in case a dev runs the script locally. But it's also ignored from committing on the repo.Relevant Issues
#227 #193
Todo
Update (FYI: @butenkor, @andrii-kovalenko-ct):