From 131a588e09c67a53ab91c4928b2896dc035f8cee Mon Sep 17 00:00:00 2001
From: Dave Syer <dsyer@pivotal.io>
Date: Thu, 17 Nov 2016 10:51:33 +0000
Subject: [PATCH] Use wro4j instead of lesscss plugin

It's better maintained and it seems to provide more features
as well.
---
 pom.xml                      | 86 +++++++++---------------------------
 src/main/less/petclinic.less |  2 -
 src/main/wro/wro.properties  |  4 ++
 src/main/wro/wro.xml         |  6 +++
 4 files changed, 30 insertions(+), 68 deletions(-)
 create mode 100644 src/main/wro/wro.properties
 create mode 100644 src/main/wro/wro.xml

diff --git a/pom.xml b/pom.xml
index e0477cb..2455ace 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.springframework.samples</groupId>
   <artifactId>springboot-petclinic</artifactId>
-  <version>1.4.1</version>
+  <version>1.4.2</version>
 
   <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
-    <version>1.4.1.RELEASE</version>
+    <version>1.4.2.RELEASE</version>
   </parent>
   <name>petclinic</name>
 
@@ -25,6 +25,7 @@
     <webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
     <webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
     <webjars-jquery.version>2.2.4</webjars-jquery.version>
+    <wro4j.version>1.8.0</wro4j.version>
 
     <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
     <thymeleaf-layout-dialect.version>2.0.4</thymeleaf-layout-dialect.version>
@@ -169,78 +170,31 @@
       </plugin>
 
       <plugin>
-        <!-- right now lesscss maven plugin does NOT support @Import from 
-          classpath https://github.com/marceloverdijk/lesscss-maven-plugin/issues/72 
-          workaround here will be unpacking the bootstrap on-the-fly remove this plugin 
-          config when the issue is resolved OR a better resolution is found -->
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
+        <groupId>ro.isdc.wro4j</groupId>
+        <artifactId>wro4j-maven-plugin</artifactId>
+        <version>${wro4j.version}</version>
         <executions>
           <execution>
-            <id>unpack</id>
-            <phase>process-resources</phase>
+            <phase>generate-resources</phase>
             <goals>
-              <goal>unpack</goal>
+              <goal>run</goal>
             </goals>
-            <configuration>
-              <artifactItems>
-                <artifactItem>
-                  <groupId>org.webjars</groupId>
-                  <artifactId>bootstrap</artifactId>
-                  <version>${webjars-bootstrap.version}</version>
-                  <overWrite>false</overWrite>
-                  <outputDirectory>${project.basedir}/target/less
-                  </outputDirectory>
-                  <includes>**/*.less</includes>
-                </artifactItem>
-              </artifactItems>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-
-      <plugin>
-        <artifactId>maven-resources-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>copy-resources</id>
-            <phase>validate</phase>
-            <goals>
-              <goal>copy-resources</goal>
-            </goals>
-            <configuration>
-              <outputDirectory>${project.build.directory}/less</outputDirectory>
-              <resources>
-                <resource>
-                  <directory>src/main/less</directory>
-                  <filtering>true</filtering>
-                </resource>
-              </resources>
-            </configuration>
           </execution>
         </executions>
-      </plugin>
-
-      <plugin>
-        <groupId>org.lesscss</groupId>
-        <artifactId>lesscss-maven-plugin</artifactId>
-        <version>1.7.0.1.1</version>
         <configuration>
-          <sourceDirectory>${project.build.directory}/less</sourceDirectory>
-          <outputDirectory>${project.build.directory}/classes/static/resources/css</outputDirectory>
-          <compress>true</compress>
-          <includes>
-            <include>petclinic.less</include>
-          </includes>
+          <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
+          <cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
+          <wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
+          <extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
+          <contextFolder>${basedir}/src/main/less</contextFolder>
         </configuration>
-        <executions>
-          <execution>
-            <phase>process-resources</phase>
-            <goals>
-              <goal>compile</goal>
-            </goals>
-          </execution>
-        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>bootstrap</artifactId>
+            <version>${webjars-bootstrap.version}</version>
+          </dependency>
+        </dependencies>
       </plugin>
     </plugins>
   </build>
diff --git a/src/main/less/petclinic.less b/src/main/less/petclinic.less
index 7364d2a..32d15a5 100644
--- a/src/main/less/petclinic.less
+++ b/src/main/less/petclinic.less
@@ -11,8 +11,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@import "META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less";
-
 @icon-font-path:    "../../webjars/bootstrap/fonts/";
 
 @spring-green:      #6db33f;
diff --git a/src/main/wro/wro.properties b/src/main/wro/wro.properties
new file mode 100644
index 0000000..bd6f3a8
--- /dev/null
+++ b/src/main/wro/wro.properties
@@ -0,0 +1,4 @@
+#List of preProcessors
+preProcessors=lessCssImport
+#List of postProcessors
+postProcessors=less4j
\ No newline at end of file
diff --git a/src/main/wro/wro.xml b/src/main/wro/wro.xml
new file mode 100644
index 0000000..590156d
--- /dev/null
+++ b/src/main/wro/wro.xml
@@ -0,0 +1,6 @@
+<groups xmlns="http://www.isdc.ro/wro">
+  <group name="petclinic">
+    <css>classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less</css>
+    <css>/petclinic.less</css>
+   </group>
+</groups>
-- 
GitLab