0

Gradlew zip task: include only those files checked in SVN?

task myTask(type: Zip) {

  from ("/path/to/my-project") {
     // only files checked into SVN/git

  }
}
eastwater
  • 4,624
  • 9
  • 49
  • 118

1 Answers1

0

Why not just call out known directories / files that shouldn't be committed? This will be gradle specific, but we're using gradle so that should be fine whether SVN or GIT is used:

task myTask( type: Zip ) {
   from("${projectDir}/**/*") {
      exclude "build/**/*", ".idea/**/*"
   }
}
chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
  • There are many other files generated, such as *.iml, *.log, out/, bin/, etc. We can list them all, but sometimes not complete. they are generated by tools. – eastwater Jun 25 '23 at 19:05
  • Sure there could be lots of things you wish to exclude. Just follow the pattern above and add additional specifics to that list. I obviously only know what you've told me about your environment so you can fill in what is missing better than I. – chubbsondubs Jun 26 '23 at 23:32
  • Is there a way to check if a file is checked into SVN or git? then use filter inside the from spec? – eastwater Jun 27 '23 at 00:40
  • I seriously would NOT do that, but you can define an alias like this: https://stackoverflow.com/a/43996664/155020 then exec it on your files. But, it's probably a seriously bad idea because that code would have to run for every file in your project every time you start up gradle. You're going to get tired of your gradle project taking minutes to just refresh. The better option is to just hard code what you want to ignore. – chubbsondubs Jun 27 '23 at 00:53
  • I've thought about this a bit more, and you might be willing to analyze every file in your project when the actual task is executed. And if that is true then you could do the alias thing and exec on every file from within a closure. `exclude { /* iterate every file here */ }` in order to make it dynamic as you wish. If you did that then gradle wouldn't try to evaluate every file every time it starts. – chubbsondubs Jun 27 '23 at 14:50