-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing class
- Loading branch information
Showing
2 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.gradle | ||
gradle | ||
build | ||
/**/gradle | ||
/**/build | ||
gradle-plugin-protobuf.i* | ||
gradle.properties | ||
.idea | ||
/.idea |
50 changes: 50 additions & 0 deletions
50
src/main/groovy/ws/antonov/gradle/plugins/protobuf/ProtobufExtract.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ws.antonov.gradle.plugins.protobuf | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.tasks.OutputDirectory | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
/** | ||
* Created by aantonov on 5/19/14. | ||
*/ | ||
class ProtobufExtract extends DefaultTask { | ||
|
||
File extractedProtosDir | ||
|
||
String configName | ||
|
||
@TaskAction | ||
def extract() { | ||
project.configurations[configName].files.each { file -> | ||
if (file.path.endsWith('.proto')) { | ||
ant.copy( | ||
file: file.path, | ||
toDir: extractedProtosDir | ||
) | ||
//generateJavaTask.getSource().create(project.files(file)) | ||
} else if (file.path.endsWith('.jar') || file.path.endsWith('.zip')) { | ||
ant.unzip(src: file.path, dest: extractedProtosDir) | ||
} else { | ||
def compression | ||
|
||
if (file.path.endsWith('.tar')) { | ||
compression = 'none' | ||
} else | ||
if (file.path.endsWith('.tar.gz')) { | ||
compression = 'gzip' | ||
} else if (file.path.endsWith('.tar.bz2')) { | ||
compression = 'bzip2' | ||
} else { | ||
throw new GradleException( | ||
"Unsupported file type (${file.path}); handles only jar, tar, tar.gz & tar.bz2") | ||
} | ||
|
||
ant.untar( | ||
src: file.path, | ||
dest: extractedProtosDir, | ||
compression: compression) | ||
} | ||
} | ||
} | ||
} |