This repository has been archived by the owner on May 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
CTPI-542: usage tracking #407
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
task setLibraryVersion { | ||
description 'If the env var "GITHUB_TAG" is set, injects the value in the ' + | ||
'service/src/main/java/com/commercetools/util/PayoneSolutionInfo.java. Otherwise, if the env var is not ' + | ||
'set it sets the version to the value "dev-version". Note: Should only be executed before compilation in ' + | ||
'the CI tool (e.g. github action.)' | ||
doLast { | ||
def versionFile = 'service/src/main/java/com/commercetools/util/PayoneSolutionInfo.java' | ||
def versionFileContents = new File(versionFile).text | ||
def versionPlaceholder = '#{LIB_VERSION}' | ||
def libVersion = 'dev-version' | ||
def tagName = System.getenv('GITHUB_TAG') | ||
|
||
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.") | ||
} | ||
|
||
// if build was triggered by a git tag, set version to tag name | ||
if (tagName) { | ||
libVersion = tagName | ||
} | ||
|
||
if (libVersion) { | ||
println "Injecting the version: '$libVersion' in $versionFile" | ||
ant.replace(file: versionFile, token: versionPlaceholder, value: libVersion) | ||
} else { | ||
throw new InvalidUserDataException("Unable to set library version in $versionFile. Please make sure the" + | ||
" var 'libVersion' is set correctly.") | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
service/src/main/java/com/commercetools/util/PayoneSolutionInfo.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,24 @@ | ||
package com.commercetools.util; | ||
|
||
import io.sphere.sdk.client.SolutionInfo; | ||
|
||
public final class PayoneSolutionInfo extends SolutionInfo { | ||
private static final String LIB_NAME = "commercetools-payone-integration"; | ||
/** This value is injected by the script at gradle-scripts/set-library-version.gradle. */ | ||
public static final String LIB_VERSION = "#{LIB_VERSION}"; | ||
public static final String LIB_WEBSITE = "https://github.com/commercetools/commercetools-payone-integration"; | ||
|
||
/** | ||
* Extends {@link SolutionInfo} class of the JVM SDK to append to the User-Agent header with | ||
* information of the commercetools-sync-java library | ||
* | ||
* <p>A User-Agent header with a solution information looks like this: {@code | ||
* commercetools-jvm-sdk/1.46.1 (AHC/2.0) Java/1.8.0_92-b14 (Mac OS X; x86_64) {@value | ||
* LIB_NAME}/{@value LIB_VERSION}} | ||
*/ | ||
public PayoneSolutionInfo() { | ||
setName(LIB_NAME); | ||
setVersion(LIB_VERSION); | ||
setWebsite(LIB_WEBSITE); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
service/src/main/resources/META-INF/services/io.sphere.sdk.client.SolutionInfo
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 @@ | ||
com.commercetools.util.PayoneSolutionInfo |
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.
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.
Are you providing "GITHUB_TAG" variable somewhere? Because I see it will be always with value
dev-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.
the github-tag is createdwhen the lib is released,