-
Notifications
You must be signed in to change notification settings - Fork 18
Compiling with resources from another jar
Considering the following:
I have a maven project A which I recently converted to Sass thanks to this plugin. I have another maven project B which has the core libraries of A as dependencies. In A, I define a set of "css constants" (colors, classes...) in a set of scss files. What is the (is there a) proper way to have an scss file import the reference scss files in module B so that it compiles properly?
unpacking the core jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack-commons-scss</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>artifactIdWhichIWantToUnpack</includeArtifactIds> <!-- I wonder if there is a better way to specify this, including the groupId to avoid any naming conflict -->
<classifier>sources</classifier>
<includes>**/_*.scss</includes> <!-- I only need the
"imported" files, not the root one, as I will use a different one in
the including module -->
<outputDirectory>${project.build.directory}/sources-sass</outputDirectory><!-- A separate work directory, to keep things clean and make investigating issues easier -->
</configuration>
</execution>
</executions>
</plugin>then, I need to copy the scss resources into the work directory (couldn't figure out a clean way to have the @import work properly otherwise):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-sass</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.scss</include>
</includes>
</resource>
</resources>
<outputDirectory>${project.build.directory}/sources-sass</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>finally, invoke the sass-maven-plugin:
<plugin>
<groupId>nl.geodienstencentrum.maven</groupId>
<artifactId>sass-maven-plugin</artifactId>
<version>2.20</version>
<configuration>
<resources>
<resource>
<source>
<directory>${project.build.directory}/sources-sass</directory>
<includes>
<include>**/*.scss</include>
</includes>
</source>
<destination>${project.build.directory}/classes</destination>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>generate-css-using-sass</id>
<goals>
<goal>update-stylesheets</goal>
</goals>
</execution>
</executions>
</plugin>see: https://github.com/GeoDienstenCentrum/sass-maven-plugin/issues/120 and https://stackoverflow.com/questions/1007211/maven-add-dependency-on-artifact-source