From e2c8c1009eeb2c645e5719b026aaf6bd45ede80b Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Mon, 11 Dec 2023 14:11:08 +0100 Subject: [PATCH] Add gradle init script for JFrog CLI --- .../workflows/continuous-integration-43x.yml | 13 +------ gradle/initscript.gradle | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 gradle/initscript.gradle diff --git a/.github/workflows/continuous-integration-43x.yml b/.github/workflows/continuous-integration-43x.yml index 0170a5f114..df8a75d5ef 100644 --- a/.github/workflows/continuous-integration-43x.yml +++ b/.github/workflows/continuous-integration-43x.yml @@ -23,11 +23,6 @@ jobs: java-version: '8' distribution: 'adopt' - - name: Extract project version - run: | - ./gradlew clean - echo PROJECT_VERSION=$(./gradlew properties | grep version | cut -d: -f2 | xargs) >> $GITHUB_ENV - - name: Setup JFrog Cli uses: jfrog/setup-jfrog-cli@901bb9632db90821c2d3f076012bdeaf66598555 # v3.4.1 env: @@ -41,11 +36,5 @@ jobs: - name: Build the project and Deploy to Artifactory run: | - jf gradle build install -x test - echo "Copying spring-batch-infrastructure/build/poms/pom-default.xml to spring-batch-infrastructure/build/libs/spring-batch-infrastructure-$PROJECT_VERSION.pom" - cp spring-batch-infrastructure/build/poms/pom-default.xml spring-batch-infrastructure/build/libs/spring-batch-infrastructure-$PROJECT_VERSION.pom - cp spring-batch-core/build/poms/pom-default.xml spring-batch-core/build/libs/spring-batch-core-$PROJECT_VERSION.pom - cp spring-batch-test/build/poms/pom-default.xml spring-batch-test/build/libs/spring-batch-test-$PROJECT_VERSION.pom - cp spring-batch-integration/build/poms/pom-default.xml spring-batch-integration/build/libs/spring-batch-integration-$PROJECT_VERSION.pom - jf gradle artifactoryPublish + jf gradle build install artifactoryPublish -x test -I gradle/initscript.gradle jf rt build-publish diff --git a/gradle/initscript.gradle b/gradle/initscript.gradle new file mode 100644 index 0000000000..4184488317 --- /dev/null +++ b/gradle/initscript.gradle @@ -0,0 +1,38 @@ +import org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin +import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask + +initscript { + dependencies { + classpath fileTree('${pluginLibDir}') + } +} + +addListener(new BuildInfoPluginListener()) + +class BuildInfoPluginListener extends BuildAdapter { + + def void projectsLoaded(Gradle gradle) { + Map projectProperties = new HashMap(gradle.startParameter.getProjectProperties()) + projectProperties.put("build.start", Long.toString(System.currentTimeMillis())) + gradle.startParameter.setProjectProperties(projectProperties) + Project root = gradle.getRootProject() + root.logger.debug("Artifactory plugin: projectsEvaluated: ${root.name}") + if (!"buildSrc".equals(root.name)) { + root.allprojects { + apply { + apply plugin: ArtifactoryPlugin + } + } + } + + // Set the "mavenJava" and "ivyJava" publications or + // "archives" configuration to all Artifactory tasks. + for (Project p : root.getAllprojects()) { + Task t = p.getTasks().findByName(ArtifactoryTask.ARTIFACTORY_PUBLISH_TASK_NAME) + if (t != null) { + ArtifactoryTask task = (ArtifactoryTask) t + task.setCiServerBuild() + } + } + } +} \ No newline at end of file