Skip to content

Commit 81613a5

Browse files
committed
Copying to target folder
1 parent a7d13cb commit 81613a5

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

plugin/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ repositories {
1010
}
1111

1212
dependencies {
13-
//compile 'net.lingala.zip4j:zip4j:1.3.2'
1413
compile gradleApi()
1514
compile localGroovy()
1615
testCompile 'junit:junit:4.11'

plugin/src/main/groovy/com/mendhak/gradlecrowdin/DownloadTranslationsTask.groovy

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mendhak.gradlecrowdin
22

3+
import groovy.io.FileType
34
import org.gradle.api.DefaultTask
45
import org.gradle.api.tasks.TaskAction
56

@@ -12,16 +13,12 @@ class DownloadTranslationsTask extends DefaultTask {
1213
def apiKey
1314
def projectId
1415

15-
File getDestination() {
16-
project.file(destination)
17-
}
18-
1916
@TaskAction
2017
def downloadTranslations() {
2118

2219
// println(apiKey)
2320
// println(projectId)
24-
println(destination)
21+
// println(destination)
2522

2623
def buildSubDir = new File(project.buildDir.getPath() , "/crowdin-plugin")
2724
buildSubDir.mkdirs()
@@ -37,7 +34,22 @@ class DownloadTranslationsTask extends DefaultTask {
3734
file << new URL(url).openStream()
3835
file.close()
3936

40-
unzipFile(translationZip, buildSubDir)
37+
//Extract to build dir/res
38+
unzipFile(translationZip, new File(buildSubDir, "res"))
39+
40+
def list = []
41+
def extractedDir = new File(buildSubDir, "res")
42+
extractedDir.eachFileRecurse (FileType.FILES) { f ->
43+
list << f
44+
}
45+
46+
//Copy to values-XYZ in the destination folder
47+
list.each {
48+
def copyTo = new File(destination, "values-"+ it.getParentFile().getName() + "/" + it.getName() )
49+
println copyTo.getPath()
50+
new AntBuilder().copy( file:it.getPath(),
51+
tofile:copyTo.getPath())
52+
}
4153
}
4254

4355
def unzipFile(File zipFile, File outputFolder){
@@ -57,7 +69,7 @@ class DownloadTranslationsTask extends DefaultTask {
5769
String fileName = ze.getName();
5870
File newFile = new File(outputFolder, fileName);
5971

60-
println("Extracting : "+ newFile.getAbsoluteFile());
72+
//println("Extracting : "+ newFile.getAbsoluteFile());
6173

6274
if(ze.isDirectory()){
6375
newFile.mkdirs()

0 commit comments

Comments
 (0)