Creating Directory in gradle script


(Ananta Jena) #1

I have a project,after compilation through gradle build,class files are generated in build folder.i want those files should be copied to classes folder under build folder.

Please provide me the code so that i can create a directory while building through gradle.

Thanks in advance

Regards, Ananta


(Peter Niederwieser) #2

I don’t understand what you are trying to do, but you can create a directory with ‘mkdir “some/path”’.


(Ananta Jena) #3

I mean to say,i need to create a directory under build folder .suppose my project is under myproject…after compilation i need to move the class files to build/MyFolder folder under project myproject.


(Peter Niederwieser) #4

So you want to copy class files from ‘build/classes/main’ to ‘build/MyFolder’?

task copyClasses(type: Copy) {
    from compileJava.outputs.files
    from processResources.outputs.files // if you need resources too
    into "build/MyFolder"
}

(Ananta Jena) #5

yes i want to move the code from ‘build/classes/main’ to ‘build/MyFolder’?

task copyClasses(type: Copy) {

from compileJava.outputs.files

from processResources.outputs.files // if you need resources too

into “build/MyFolder”

}

but MyFolder is not there ,1st i need to create one folder named MyFolder than i will copy


(Peter Niederwieser) #6

It will be created automatically.


(Ananta Jena) #7

So if i write only folder name like from build/RUSSAI then RUSSIA folder will be created under build…

Please correct me if i am wrong


(Peter Niederwieser) #8

Yes. Why not just give it a try.


(Ananta Jena) #9

Thanks a lot Peter.,thaanks once again…i am ooo office,i will try and definitely responding to your post…

can you please give me your email id…my self is ananta.cet@gmail.com.

I really wants to be your friend…if you dont mind…

regards, Ananta


(Ananta Jena) #10

Hi peter,

Still i am unable to create a new folder in unix machine through gradle . As far as local is concerned yes the directory is created successfully…but it’s failing in unix machine.

mkdir(‘build/MyFolder’) doesn’t work on unix machine