Search code examples
javagradlelog4jsalesforceapex-data-loader

How do I display log4j output for a Gradle JavaExec task?


I would like to use Gradle tasks to execute java commands for the salesforce dataloader so that we can have our data loading tasks in a self-contained project. I've installed the dataloader into my local maven repo and set up my gradle project as follows:

build.gradle:

apply plugin: 'groovy'

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    compile gradleApi()
    compile 'com.force:dataloader:42.0.0'
    compile 'org.codehaus.groovy:groovy-all:2.4.7'
}

task generateKey(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath

    main = 'com.salesforce.dataloader.security.EncryptionUtil'

    args '-g', 'seedText'
}

The Problem

When I execute gradle generateKey, the task completes successfully but none of the output from the EncryptionUtil is shown. I suspect this is because the dataloader uses a log4j logger and not printing directly to standard out? Is there some further configuration I need to do?

I've also tried a task that calls EncryptionUtil.main('-g', 'seedText') directly, but that also won't show any output unless I run the task in --info mode.

Thanks for your help! I appreciate feedback and any options I'm not thinking of. We're a gradle shop but maybe there is a better solution.


Solution

  • Blargh. I wasn't using ./gradlew. Move along, nothing to see here.