Skip to content

Commit

Permalink
Add gradle init script for JFrog CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
fmbenhassine committed Dec 11, 2023
1 parent 5ad5ff9 commit e2c8c10
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/continuous-integration-43x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
38 changes: 38 additions & 0 deletions gradle/initscript.gradle
Original file line number Diff line number Diff line change
@@ -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<String, String> projectProperties = new HashMap<String, String>(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()
}
}
}
}

0 comments on commit e2c8c10

Please sign in to comment.