Author: kishore
Date: Thu Apr 27 22:49:54 2017
New Revision: 1792966
URL: http://svn.apache.org/viewvc?rev=1792966&view=rev
Log:
Added MCFLessCompiler to compile less files
Updated pom.xml maven task to compile less files
Added:
manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/src/main/java/org/apache/manifoldcf/less/
manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/src/main/java/org/apache/manifoldcf/less/MCFLessCompiler.java
(with props)
Modified:
manifoldcf/branches/CONNECTORS-1418/framework/.gitignore
manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/pom.xml
Modified: manifoldcf/branches/CONNECTORS-1418/framework/.gitignore
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1418/framework/.gitignore?rev=1792966&r1=1792965&r2=1792966&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1418/framework/.gitignore (original)
+++ manifoldcf/branches/CONNECTORS-1418/framework/.gitignore Thu Apr 27
22:49:54 2017
@@ -2,4 +2,5 @@
/.project
/dist/
/build/
+/target/
*/target/
Modified: manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/pom.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/pom.xml?rev=1792966&r1=1792965&r2=1792966&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/pom.xml Thu Apr 27
22:49:54 2017
@@ -31,28 +31,34 @@
<build>
<plugins>
<plugin>
- <groupId>org.lesscss</groupId>
- <artifactId>lesscss-maven-plugin</artifactId>
- <version>1.7.0.1.1</version>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.6.0</version>
+
<configuration>
-
<sourceDirectory>${project.basedir}/src/main/webapp/less</sourceDirectory>
-
<outputDirectory>${project.build.directory}/${project.build.finalName}/css</outputDirectory>
- <compress>true</compress>
- <includes>
- <include>main.less</include>
- </includes>
+ <mainClass>org.apache.manifoldcf.less.MCFLessCompiler</mainClass>
+ <arguments>
+
<argument>${project.basedir}/src/main/webapp/less/style.less</argument>
+
<argument>${project.build.directory}/${project.build.finalName}/css/style.css</argument>
+ <argument>true</argument>
+ </arguments>
</configuration>
<executions>
<execution>
- <goals>
- <goal>compile</goal>
- </goals>
+ <id>compile-less</id>
+ <!-- Currently during process-classes phase, css is generated,
but during the package phase,
+ the generated css will be over written by the file from source
css folder. It's intentional for now,
+ but once the decision is made about approach, we can change the
phase to prepare-package -->
+ <phase>process-classes</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
-
+
<dependencies>
<!-- Internal dependencies -->
<dependency>
@@ -150,6 +156,13 @@
<scope>runtime</scope>
</dependency>
+ <!-- Less compiler -->
+ <dependency>
+ <groupId>com.github.sommeri</groupId>
+ <artifactId>less4j</artifactId>
+ <version>1.17.2</version>
+ </dependency>
+
</dependencies>
</project>
Added:
manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/src/main/java/org/apache/manifoldcf/less/MCFLessCompiler.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/src/main/java/org/apache/manifoldcf/less/MCFLessCompiler.java?rev=1792966&view=auto
==============================================================================
---
manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/src/main/java/org/apache/manifoldcf/less/MCFLessCompiler.java
(added)
+++
manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/src/main/java/org/apache/manifoldcf/less/MCFLessCompiler.java
Thu Apr 27 22:49:54 2017
@@ -0,0 +1,139 @@
+/* $Id$ */
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.less;
+
+
+import com.github.sommeri.less4j.Less4jException;
+import com.github.sommeri.less4j.LessCompiler;
+import com.github.sommeri.less4j.LessSource;
+import com.github.sommeri.less4j.core.DefaultLessCompiler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+
+import java.io.*;
+
+/**
+ * Created by Kishore Kumar on 4/28/17.
+ */
+public class MCFLessCompiler
+{
+ final static String lessFolderPath =
"./framework/crawler-ui/src/main/webapp/less";
+ final static String cssFolderPath =
"./framework/crawler-ui/src/main/webapp/css";
+ boolean compress = false;
+
+ private LessCompiler.Configuration createConfiguration(File cssOutut)
+ {
+
+ LessCompiler.Configuration configuration = new
LessCompiler.Configuration();
+ configuration.setCssResultLocation(new LessSource.FileSource(cssOutut));
+ configuration.setCompressing(compress);
+
+ return configuration;
+ }
+
+ public void compile(String inputLess)
+ {
+ String outputCSS = null;
+ if (inputLess != null && !inputLess.isEmpty())
+ outputCSS = FilenameUtils.removeExtension(inputLess) + ".css";
+ compile(inputLess, outputCSS);
+ }
+
+ public void compile(String inputLess, String outputCSS)
+ {
+ compile(inputLess, outputCSS, false);
+ }
+
+ public void compile(String inputLess, String outputCSS, boolean compress)
+ {
+ this.compress = compress;
+ LessCompiler compiler = new DefaultLessCompiler();
+ try
+ {
+ LessCompiler.Configuration configuration = createConfiguration(new
File(outputCSS));
+ LessCompiler.CompilationResult compilationResult = compiler.compile(new
LessSource.FileSource(new File(inputLess)), configuration);
+
+ if (compilationResult.getWarnings().size() > 0)
+ {
+ for (LessCompiler.Problem warning : compilationResult.getWarnings())
+ {
+ System.err.println(warning);
+ }
+ }
+ else
+ {
+ if (outputCSS != null && !outputCSS.isEmpty())
+ {
+ FileUtils.writeStringToFile(new File(outputCSS),
compilationResult.getCss());
+ }
+
+ //Generate Source map if compressing
+ if (compress)
+ {
+ String cssFileName = FilenameUtils.removeExtension(outputCSS);
+ String mapFileName = cssFileName + ".map";
+ FileUtils.writeStringToFile(new File(mapFileName),
compilationResult.getSourceMap());
+ }
+ }
+ }
+ catch (Less4jException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String... args)
+ {
+
+ String outputLess = lessFolderPath + "/style.less";
+ //TODO: Need to change to actual name in final impl
+ String outputCSS = cssFolderPath + "/style_test.css";
+ boolean compress = false;
+
+ MCFLessCompiler compiler = new MCFLessCompiler();
+
+ switch (args.length)
+ {
+ case 1:
+ outputLess = args[0];
+ compiler.compile(outputLess);
+ break;
+ case 2:
+ outputLess = args[0];
+ outputCSS = args[1];
+ compiler.compile(outputLess, outputCSS);
+ break;
+ case 3:
+ outputLess = args[0];
+ outputCSS = args[1];
+ compress = Boolean.valueOf(args[2]);
+ compiler.compile(outputLess, outputCSS, compress);
+ break;
+ default:
+ compiler.compile(outputLess, outputCSS, compress);
+
+ }
+
+ }
+
+}
Propchange:
manifoldcf/branches/CONNECTORS-1418/framework/crawler-ui/src/main/java/org/apache/manifoldcf/less/MCFLessCompiler.java
------------------------------------------------------------------------------
svn:eol-style = native