diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
index 8fba2e3c5d..973923af3c 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/cd.yml
@@ -22,14 +22,11 @@ jobs:
     steps:
       - name: Git Checkout
         uses: actions/checkout@v3
-      - name: Fetch Library version
-        id: vars
-        run: echo ::set-output name=libVersion::${GITHUB_REF#refs/*/}
       - name: benchmark test
         if: ${{ success() }}
-        run: ./gradlew clean setLibraryVersion benchmark
+        run: ./gradlew -Dbuild.version="${{ github.ref_name }}" clean benchmark
         env:
-          GITHUB_TAG: ${{ steps.vars.outputs.libVersion }}
+          GITHUB_TAG: ${{ github.ref_name }}
   deployment:
     name: deployment
     needs: benchmark_tests
@@ -39,22 +36,19 @@ jobs:
     steps:
       - name: Git Checkout
         uses: actions/checkout@v3
-      - name: Set output
-        id: vars
-        run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
       - name: Set up Java
         uses: actions/setup-java@v3
         with:
           java-version: 11
           distribution: 'zulu'
       - name: status
-        run: echo Build is tagged. Uploading artifact ${{ steps.vars.outputs.tag }} to maven central.
+        run: echo Build is tagged. Uploading artifact ${{ github.ref_name }} to maven central.
       - name: Publish GitHub Pages
-        run: ./gradlew --info -Dbuild.version="${{ steps.vars.outputs.tag }}" mkdocsPublish
+        run: ./gradlew --info -Dbuild.version="${{ github.ref_name }}" mkdocsPublish
       - name: deploy to sonatype and publish to maven central
-        run: ./gradlew setLibraryVersion -Dbuild.version="${{ steps.vars.outputs.tag }}" publishToSonatype closeAndReleaseSonatypeStagingRepository
+        run: ./gradlew -Dbuild.version="${{ github.ref_name }}" publishToSonatype closeAndReleaseSonatypeStagingRepository
         env:
-          GITHUB_TAG: ${{ steps.vars.outputs.tag }}
+          GITHUB_TAG: ${{ github.ref_name }}
           MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
           MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
           PGP_KEY: ${{ secrets.PGP_KEY }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 66ce3b03bf..17ac27f225 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -31,7 +31,7 @@ jobs:
           java-version: 11
           distribution: 'zulu'
       - name: Build with Gradle
-        run: ./gradlew clean setLibraryVersion test integrationTest jacocoTestCoverageVerification jacocoTestReport
+        run: ./gradlew clean test integrationTest jacocoTestCoverageVerification jacocoTestReport
         env:
           SOURCE_PROJECT_KEY: java-sync-source
           SOURCE_CLIENT_ID:  ${{ secrets.SOURCE_CLIENT_ID }}
@@ -58,11 +58,8 @@ jobs:
     steps:
       - name: Git Checkout
         uses: actions/checkout@v3
-      - name: Fetch Library version
-        id: vars
-        run: echo ::set-output name=libVersion::${GITHUB_REF#refs/*/}
       - name: benchmark test
         if: ${{ success() }}
-        run: ./gradlew clean setLibraryVersion benchmark
+        run: ./gradlew -Dbuild.version="${{ github.ref_name }}" clean benchmark
         env:
-          GITHUB_TAG: ${{ steps.vars.outputs.libVersion }}
+          GITHUB_TAG: ${{ github.ref_name }}
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index b4a424d68c..7eeb2ce609 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -79,7 +79,7 @@ If you have push access to the repository you can fix them directly otherwise ju
 
 ##### Build and publish to Maven Central
 ````bash
-./gradlew clean setLibraryVersion -Dbuild.version={version} publishToSonatype closeAndReleaseSonatypeStagingRepository
+./gradlew clean -Dbuild.version={version} publishToSonatype closeAndReleaseSonatypeStagingRepository
 ````
 
 For more detailed information on the build and the release process, see [Build and Release](BUILD.md) documentation.
diff --git a/gradle-scripts/execution-order.gradle b/gradle-scripts/execution-order.gradle
index 0c6bd2586e..236d1a7d1d 100644
--- a/gradle-scripts/execution-order.gradle
+++ b/gradle-scripts/execution-order.gradle
@@ -41,7 +41,6 @@ check.dependsOn jacocoTestReport
 // Ensure jacocoTestCoverageVerification and jacocoTestReport run after integrationTest
 jacocoTestCoverageVerification.mustRunAfter integrationTest
 jacocoTestReport.mustRunAfter integrationTest
-// Ensure build runs after setLibraryVersion
-build.mustRunAfter setLibraryVersion
+compileJava.dependsOn versionTxt
 // Ensure benchmark results are only committed runs after the benchmarks are run
 benchmarkCommit.mustRunAfter benchmark
diff --git a/gradle-scripts/set-library-version.gradle b/gradle-scripts/set-library-version.gradle
index f2d1fe9617..f799a93a12 100644
--- a/gradle-scripts/set-library-version.gradle
+++ b/gradle-scripts/set-library-version.gradle
@@ -1,32 +1,20 @@
-task setLibraryVersion {
-    description 'If the env var "GITHUB_TAG" is set, injects the value in the ' +
-            'src/main/java/com/commercetools/sync/commons/utils/SyncSolutionInfo.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 = 'src/main/java/com/commercetools/sync/commons/utils/SyncSolutionInfo.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.")
+sourceSets {
+    main {
+        java {
+            srcDir 'build/generated/src/main/java'
         }
+    }
+}
 
-        // if build was triggered by a git tag, set version to tag name
-        if (tagName) {
-            libVersion = tagName
-        }
+task versionTxt()  {
+    doLast {
+        new File(projectDir, "build/generated/src/main/java/com/commercetools/sync/").mkdirs()
+        new File(projectDir, "build/generated/src/main/java/com/commercetools/sync/BuildInfo.java").text = """
+package com.commercetools.sync;
 
-        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.")
-        }
+public class BuildInfo {
+    public static final String VERSION = "$version";
+}
+"""
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/commercetools/sync/commons/utils/SyncSolutionInfo.java b/src/main/java/com/commercetools/sync/commons/utils/SyncSolutionInfo.java
index 3729621532..a78416aadb 100644
--- a/src/main/java/com/commercetools/sync/commons/utils/SyncSolutionInfo.java
+++ b/src/main/java/com/commercetools/sync/commons/utils/SyncSolutionInfo.java
@@ -1,11 +1,12 @@
 package com.commercetools.sync.commons.utils;
 
+import com.commercetools.sync.BuildInfo;
 import io.sphere.sdk.client.SolutionInfo;
 
 public final class SyncSolutionInfo extends SolutionInfo {
   private static final String LIB_NAME = "commercetools-sync-java";
   /** 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_VERSION = BuildInfo.VERSION;
 
   /**
    * Extends {@link SolutionInfo} class of the JVM SDK to append to the User-Agent header with