Skip to content
Browse files

added localization conventions

  • Loading branch information...
1 parent 8915835 commit 9a43f665efffac6fd751978b7a2eb4f6cb158ef3 @RIAstar RIAstar committed Mar 5, 2012
View
6 src/main/groovy/org/gradlefx/conventions/GradleFxConvention.groovy
@@ -41,6 +41,12 @@ class GradleFxConvention {
//test resource directories
def testResourceDirs = ['src/test/resources']
+
+ //locale root directory
+ def localeDir = 'src/main/locale'
+
+ //array of locales; maps to the locale compiler option
+ def locales = []
//equivalent of the include-classes compiler option
List includeClasses;
View
31 src/main/groovy/org/gradlefx/tasks/compile/AbstractCompileTask.groovy
@@ -20,8 +20,6 @@ import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ResolveException
import org.gradlefx.FlexType
-import org.slf4j.LoggerFactory
-import org.slf4j.Logger
abstract class AbstractCompileTask extends DefaultTask {
@@ -39,6 +37,33 @@ abstract class AbstractCompileTask extends DefaultTask {
private def initOutputDirectory() {
outputs.dir project.buildDir
}
+
+ /**
+ * Adds all the source paths (project.srcDirs) including the locale path (project.localeDir) as compile arguments
+ * @param compilerArguments
+ */
+ protected void addSourcePaths(List compilerArguments) {
+ //add locale path to source paths if any locales are defined
+ if (project.locales && project.locales.size()) {
+ project.srcDirs.add project.localeDir
+ }
+
+ project.srcDirs.each { sourcePath ->
+ File sourcePathDir = project.file(sourcePath)
+ String path = project.file(sourcePath).path
+ if (sourcePath == project.localeDir) path += '/{locale}'
+
+ if (sourcePathDir.exists() || sourcePath.contains('{')) {
+ compilerArguments.add("-source-path+=" + path)
+ }
+ }
+ }
+
+ protected void addLocales(List compilerArguments) {
+ if (project.locales && project.locales.size()) {
+ compilerArguments.add("-locale=" + project.locales.join(','))
+ }
+ }
/**
* Adds all the dependencies for the given configuration as compile arguments
@@ -48,7 +73,7 @@ abstract class AbstractCompileTask extends DefaultTask {
protected void addLibraries(Set libraryFiles, Configuration configuration, String compilerArgument, List compilerArguments) {
libraryFiles.each { dependency ->
//only add swc dependencies, no use in adding pom dependencies
- if (dependency.name.endsWith(FlexType.swc.toString()) || dependency.isDirectory()) {
+ if (dependency.name.endsWith(FlexType.swc.toString())) {
if (!dependency.exists()) {
String errorMessage = "Couldn't find the ${dependency.name} file - are you sure the path is correct? "
errorMessage += "Dependency path: " + dependency.path
View
11 src/main/groovy/org/gradlefx/tasks/compile/Compc.groovy
@@ -64,6 +64,7 @@ class Compc extends AbstractCompileTask {
addSourcePaths(compilerArguments)
addSourceFilesAndDirectories(compilerArguments)
addResources(compilerArguments)
+ addLocales(compilerArguments)
//add dependencies
addLibraries(project.configurations.internal.files, project.configurations.internal, "-include-libraries", compilerArguments)
@@ -94,16 +95,6 @@ class Compc extends AbstractCompileTask {
}
}
- private def addSourcePaths(List compilerArguments) {
- project.srcDirs.each { sourcePath ->
- File sourcePathDir = project.file(sourcePath)
- //don't allow non existing source paths unless they contain a token (e.g. {locale})
- if(sourcePathDir.exists() || sourcePath.contains('{')) {
- compilerArguments.add("-source-path+=" + project.file(sourcePath).path)
- }
- }
- }
-
private def addSourceFilesAndDirectories(List compilerArguments) {
if (project.includeClasses == null && project.includeSources == null) {
project.srcDirs.each { sourcePath ->
View
5 src/main/groovy/org/gradlefx/tasks/compile/Mxmlc.groovy
@@ -38,9 +38,8 @@ class Mxmlc extends AbstractMxmlc {
List compilerArguments = []
//add every source directory
- project.srcDirs.each { sourcePath ->
- compilerArguments.add("-source-path+=" + project.file(sourcePath).path)
- }
+ addSourcePaths(compilerArguments)
+ addLocales(compilerArguments)
//add dependencies
addLibraries(project.configurations.internal.files, project.configurations.internal, "-include-libraries", compilerArguments)

0 comments on commit 9a43f66

Please sign in to comment.
Something went wrong with that request. Please try again.