mardi 21 juin 2016

Why does Gradle create files in another git branch?

I am currently having some problems with Gradle and Git.

I am using the fxlauncher to automatically update my application. It is configured using Gradle's build process. Here is the build.gradle file of the root project:

group 'de.zerotask'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

subprojects {
    apply plugin: 'java'
    apply plugin: 'maven'

    sourceCompatibility = 1.8

    repositories {
        mavenCentral()
    }

    group 'de.zerotask'
    version = rootProject.version


}

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'

    compile project(':fx-framework')
    compile project(':guice-injector')

    compile 'no.tornado:fxlauncher:1.0.11'
}

// This part creates the app manifest needed for updating app

// Installer Filename without suffix
def appFilename = 'Taskflow'

// The JavaFX Application class name
def appMainClass = 'de.zerotask.taskflow.TaskflowApplication'

// Optional override to specify where the cached files are stored. Default is current working directory
def cacheDir = 'cache'

// Optional parameters to the application, will be embedded in the launcher and can be overriden on the command line
def appParameters = ''

// The Application vendor used by javapackager
def appVendor = 'Zerotask'

// The Application version used by javapackager
def appVersion = '1.0'

// Base URL where you will host the application artifacts
def appUrl = 'https://sirwindfield.github.io/taskflow/application-content/'

// Optional scp target for application artifacts hosted at the above url
def appDeployTarget = ''

jar.archiveName = "taskflow.jar"

task buildApp(dependsOn: ['copyDependencies', 'generateAppManifest', 'embedAppManifest'])

task copyDependencies {
    dependsOn jar
    configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
        project.copy {
            from artifact.file
            into 'build/libs'
            rename { "${artifact.name}.${artifact.extension}" }
        }
    }
}

task generateAppManifest(type: JavaExec) {
    main = 'fxlauncher.CreateManifest'
    classpath = sourceSets.main.runtimeClasspath
    args = [appUrl, appMainClass, 'build/libs', '--cache-dir=' + cacheDir, appParameters]
}

task embedAppManifest(type: Exec) {
    mustRunAfter 'generateAppManifest'
    workingDir 'build/libs'
    commandLine 'jar', 'uf', 'fxlauncher.jar', 'app.xml'
}

task installer(type: Exec, dependsOn: 'buildApp') {
    commandLine 'javapackager', '-deploy', '-native', '-outdir', 'installer', '-outfile', appFilename, '-srcdir', 'build/libs', '-srcfiles', 'fxlauncher.jar', '-appclass', 'fxlauncher.Launcher', '-name', "${rootProject.name}", '-title', "${rootProject.name}", '-vendor', "$appVendor", "-Bidentifier", "${rootProject.group}.${appFilename}", '-Bidentifier=' + project.group + '.' + appFilename, '-BappVersion=' + appVersion
}

task deployApp(type: Exec, dependsOn: 'embedAppManifest') {
    workingDir 'build/libs'
    // commandLine 'scp', '-r', '.', appDeployTarget
}

This should all happen on master. I made sure that I switched branches before executing the buildApp task with gradle. After the tasks finishes, I switched over to the gh-pages branch. Gradle also created here the build directory along with each submodule's build directory. I have no idea why. I thought that file changes should only happen on the current branch and not on others.

If someone could help my out on how to fix this and explain me why it is happening, it would really make me happy!

Aucun commentaire:

Enregistrer un commentaire