This is an automated email from the git hooks/post-receive script. New commit to branch develop-2.x in repository jaxx. See http://git.nuiton.org/jaxx.git commit 10b7dbd0dabf173ab5fd8ee1cecf9054c25b5030 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Jan 15 19:12:29 2016 +0100 Can configure jaxx css file extension (See #3868) --- .../java/jaxx/compiler/CompilerConfiguration.java | 13 +++++++++ .../compiler/DefaultCompilerConfiguration.java | 5 ++++ .../main/java/jaxx/compiler/JAXXCompilerFile.java | 33 +++++++++++----------- .../src/main/java/jaxx/compiler/JAXXEngine.java | 4 +-- .../java/org/nuiton/jaxx/plugin/GenerateMojo.java | 13 +++++++++ 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java b/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java index efc8214..59da9a7 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java @@ -38,6 +38,13 @@ import java.util.Map; */ public interface CompilerConfiguration { + /** + * Default css file extension. + * + * @since 2.28 + */ + String DEFAULT_CSS_EXTENSION = "css"; + /** @return the class loader used by compilers */ ClassLoader getClassLoader(); @@ -151,4 +158,10 @@ public interface CompilerConfiguration { * @since 2.13 */ File getCommonCss(); + + /** + * @return the extension of css files (by default use {@link #DEFAULT_CSS_EXTENSION} as before). + * @since 2.28 + */ + String getCssExtension(); } diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java b/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java index 419ddfb..1bfa116 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java @@ -335,6 +335,11 @@ public class DefaultCompilerConfiguration implements CompilerConfiguration { return commonCss; } + @Override + public String getCssExtension() { + return DEFAULT_CSS_EXTENSION; + } + public void setCommonCss(File commonCss) { this.commonCss = commonCss; } diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFile.java b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFile.java index 0639d14..f0fecd7 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFile.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerFile.java @@ -63,9 +63,17 @@ public class JAXXCompilerFile { /** compiler associated to the file */ protected JAXXCompiler compiler; - public JAXXCompilerFile(File basedir, File jaxxFile) { + /** + * Css file extension. + * + * @see CompilerConfiguration#getCssExtension() + */ + protected final String cssExtension; + + public JAXXCompilerFile(File basedir, File jaxxFile, String cssExtension) { this.basedir = basedir; this.jaxxFile = jaxxFile; + this.cssExtension = cssExtension; String absolutePath = jaxxFile.getAbsolutePath(); String baseAbsolutePath = basedir.getAbsolutePath(); if (!absolutePath.startsWith(baseAbsolutePath)) { @@ -79,20 +87,18 @@ public class JAXXCompilerFile { } } - public JAXXCompilerFile(File jaxxFile, String className) { + public JAXXCompilerFile(File jaxxFile, String className, String cssExtension) { this.jaxxFile = jaxxFile; this.className = className; + this.cssExtension = cssExtension; String extension = FileUtil.extension(jaxxFile); String[] paths = className.split("\\."); File basedir = jaxxFile; for (int i = paths.length - 1; i > -1; i--) { if (basedir == null) { - throw new IllegalStateException( - "Could not find base dir for " + jaxxFile + - " according to fqn " + className - ); + throw new IllegalStateException("Could not find base dir for " + jaxxFile + " according to fqn " + className); } String path = paths[i]; @@ -103,10 +109,7 @@ public class JAXXCompilerFile { // check path = base filename if (!path.equals(basedir.getName())) { - throw new IllegalStateException( - "Should have found directory " + path + ", but was " + - basedir.getName() - ); + throw new IllegalStateException("Should have found directory " + path + ", but was " + basedir.getName()); } basedir = basedir.getParentFile(); @@ -118,9 +121,7 @@ public class JAXXCompilerFile { // must guess the base directory and relative path - String relativePath = jaxxFile.getAbsolutePath().substring( - basedir.getAbsolutePath().length() + 1 - ); + String relativePath = jaxxFile.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1); if (log.isDebugEnabled()) { log.debug("relative path = " + relativePath); @@ -155,10 +156,8 @@ public class JAXXCompilerFile { public URL getJAXXFileURL() { File file = getJaxxFile(); - URL url = null; try { - url = file.toURI().toURL(); - return url; + return file.toURI().toURL(); } catch (MalformedURLException e) { throw new IllegalStateException("Url of the jaxx file is malformed... " + file); } @@ -170,7 +169,7 @@ public class JAXXCompilerFile { String extension = FileUtil.extension(file); String fileName = file.getName(); int length = fileName.length() - extension.length(); - String identCssFilename = fileName.substring(0, length) + "css"; + String identCssFilename = fileName.substring(0, length) + cssExtension; cssFile = new File(file.getParentFile(), identCssFilename); } return cssFile; diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java index 80fcad2..221561b 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java @@ -101,7 +101,7 @@ public class JAXXEngine { // add all default files to compile for (String relativePath : relativePaths) { JAXXCompilerFile compilerFile = - new JAXXCompilerFile(base, new File(base, relativePath)); + new JAXXCompilerFile(base, new File(base, relativePath), configuration.getCssExtension()); addFileToCompile(compilerFile); } @@ -395,7 +395,7 @@ public class JAXXEngine { log.debug("file = " + jaxxFile + ", fqn = " + jaxxClassName); } - JAXXCompilerFile file = new JAXXCompilerFile(jaxxFile, jaxxClassName); + JAXXCompilerFile file = new JAXXCompilerFile(jaxxFile, jaxxClassName, configuration.getCssExtension()); addFileToCompile(file); } diff --git a/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java b/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java index 7b3de10..a041ce7 100644 --- a/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java +++ b/jaxx-maven-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java @@ -310,6 +310,14 @@ public class GenerateMojo extends AbstractJaxxMojo implements CompilerConfigurat private File commonCss; /** + * The extension of css files. + * + * @since 2.28 + */ + @Parameter(property = "jaxx.cssExtension", defaultValue = DEFAULT_CSS_EXTENSION) + private String cssExtension; + + /** * Decorators available in engine. * * @since 2.0.2 @@ -659,6 +667,11 @@ public class GenerateMojo extends AbstractJaxxMojo implements CompilerConfigurat return commonCss; } + @Override + public String getCssExtension() { + return cssExtension; + } + public JAXXEngine getEngine() { return engine; } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.