0

Gradle 2.13 Revision: 3b427b1481e46232107303c90be7b05079b05b1c OS: Linux 3.10.0-327.36.3.el7.x86_64 amd64

In linux on calling the clean task the contents of buildDir path are not deleted whereas the same in windows deletes the contents of buildDir(expected behaviour). Whats the reason ?

Code sample

apply plugin : 'java'
ant.importBuild 'build.xml'
sourceCompatibility = 1.8
def projVersion = ant.properties['version']
def projName = "xyz"
def buildPath = "/home/test/build"
def dependencyPath = "/home/test/dependency"
buildDir = new File("$buildPath","$projName")
def serviceDirBin = new File(buildDir , 'bin')
def serviceDirConf = new File(buildDir , 'conf')
def serviceDirThirdparty = new File(buildDir , 'thirdparty')

repositories    {
        flatDir {
            dirs file("$dependencyPath"),
        }
    }


sourceSets{
    main{
        java{
            srcDir 'src'
            }
        output.classesDir 'classes'
        }
    test{
        java {
            srcDir  'src/test'
              }
        }
}

dependencies {
    /*Some compile dependencies*/
}

jar{
    destinationDir = new File(serviceDirThirdparty, 'lib')
    baseName='xyz'
    manifest {

        'Build-Timestamp': new Date().format('yyyy-dd-MM HH:mm:ss'),
        'Specification-Version': '1.0',
        'Implementation-Version': "$projVersion"
    }
}

task xyzpackager << {

    copy{
            from ("$buildPath/sf/distribution/bin")
            into file(serviceDirBin)
        }
    copy{
            from ('conf')
            into file(serviceDirConf)
        }
    copy{
            from configurations.compile
            from configurations.runtime
            into new File(serviceDirThirdparty,'lib')
        }

}


test {
    reports {
        html.enabled = false
        junitXml.enabled = true


        junitXml.destination = file("TestReport/xml")
            }
}

jar.doLast {

            delete "$buildDir/tmp","$buildDir/dependency-cache","$buildDir/classes","$buildDir/libs"
        }
compileTestJava.doLast{
delete "TestReport"
}

the jar is copied to thirdparty folder and the bin/conf folders have some other files. SO basically i want to delete the buildDir before every new build

jugal
  • 279
  • 3
  • 7
  • 19
  • Try `gradle --stop` first. I'm trying to see if there's a daemon holding a lock on one of the files – lance-java Mar 03 '17 at 10:46
  • Have you changed `$buildDir` from the default (ie "build"). Is the case of the directory name exactly the same? – lance-java Mar 03 '17 at 10:47
  • @LanceJava there are no gradle daemons running. yes the $buildDir is changed from the default to a customized path. And yes the directory name is same. I have tried it for multiple projects – jugal Mar 03 '17 at 10:54
  • @LanceJava are you able to replicate this at your side? – jugal Mar 03 '17 at 11:01
  • @jugal can you provide an MVCE? – Vampire Mar 03 '17 at 11:07
  • @Vampire pls see the edit if thats helpful – jugal Mar 03 '17 at 11:26
  • @jugal not really, it misses the C of MCVE: http://stackoverflow.com/help/mcve – Vampire Mar 03 '17 at 11:41
  • @Vampire the edit now has more or less the actual code – jugal Mar 03 '17 at 12:15
  • After fixing the syntax errors in your buildscript I tried it on Windows and Linux. I called `gradlew jar` and `gradlew clean`. After the first command the JAR was in the custom build directory, after the second command the custom build directory was empty on both OS. The only difference is, that the path you are using is absolute on *nix and relative on Windows, meaning on Windows the folder is `home/test/...` inside the project directory and `/home/test/...` on *nix. – Vampire Mar 03 '17 at 13:48

0 Answers0