Create a directory structure from a path in gradle/groovy

后端 未结 1 360
灰色年华
灰色年华 2021-01-21 06:01

I am implementing a diff package generation task in my project\'s gradle build from the git command line output. Currently I have a method which will give me a list of changed f

相关标签:
1条回答
  • 2021-01-21 06:39

    My current plan is to split the string repo/dir/file.java on the forward slash, and create directories until the last element of the split result

    Rather than splitting your string manually, you could try using File.mkdirs():

    File newDirectoryStructureParent = new File('some/path/to/parent/dir')
    
    def s = 'repo/dir/file.java'
    def newContainer = new File(s, newDirectoryStructureParent).getParent()
    newContainer.mkdirs()
    
    0 讨论(0)
提交回复
热议问题