12

referring to SASS implementation for Java? :

What is the best way to auto-compile compass-style.org stylesheets in maven goal compile respectively package?

I would not like to ship too many self-compiled libraries nor do I want to dynamically ship compiled files via filters like https://code.google.com/p/sass-java ( https://github.com/darrinholst/sass-java )

Any alternatives than hooking up shellscripts / ant scripts which requires installed ruby and compass on the client?

What is the detailed difference between SASS and Compass Stylesheets, any problems with "sass-tools" when regularly using "compass"? => Which mvn plugins are "compass aware"?!

Community
  • 1
  • 1
childno͡.de
  • 4,679
  • 4
  • 31
  • 57

5 Answers5

6

I found this, it's not a special compass/sass plugin but it works

https://gist.github.com/1671207

maxb
  • 486
  • 3
  • 14
  • doesn't need ruby on shell, doesn't have any other dependencies, uses java only...that like what I'm looking for. Not perfect but almost good enough! Thank you very much. – childno͡.de Sep 04 '12 at 17:26
6

I suppose you know about this Maven plugin (mentioned in SASS implementation for Java?)? : https://github.com/Jasig/sass-maven-plugin

(I haven't tried it myself yet.)

UPDATE: that plugin is no longer supported. However, this fork seems to be healthy at present, so it might be an option for some: https://github.com/GeoDienstenCentrum/sass-maven-plugin

Community
  • 1
  • 1
seanf
  • 6,504
  • 3
  • 42
  • 52
2

I was using the Sass Maven Plugin by nl.geodienstencentrum.maven but it uses Ruby and is very slow.

I've now switched to: Libsass Maven Plugin

https://github.com/warmuuh/libsass-maven-plugin

This uses C and our compile times are much less (8.6 seconds to -> 2 seconds)

DD.
  • 21,498
  • 52
  • 157
  • 246
  • This solution is superior to the jruby version. It's much faster and addtional options like `include_path` and `outputStyle` actually works. – Isen Ng Oct 29 '21 at 01:15
1

I tried several ways to compile my app (java, Wicket, using Zurb Foundation Sites, node-sass with depebndency of lib-sass). To tell you the truth, all the maven plugins were somewhere a deadend, especially when my scss contained the !global flag. (This flag came with foundations.) So the final solution for us was to build with npm first then use maven. Npm builds into src/main/webapp/"myDir" dir. I excluded this dir in git. The jason file has a line like:

"scripts": {
    ....
    "build-css": "node node_modules/node-sass/bin/node-sass --include-path myScssDir myScssDir/myScss.scss --output  src/main/webapp/myDir/css",
    ....
}

Then build with maven and it will move the builded css ino my war. For some help (create the nonexisting "myDir" dir) i used mkdirp. In my jason there is:

"scripts": {
    "create-dirs": "mkdirp src/main/webapp/myDir/",
    ....
}

So i run "npm i" to install all my dependencies locally into node-modules dir. This is gitignored.

Then i run "npm run create-dirs" to create the necessary myDir. This is gitignored as well.

Then i run "npm run build-css" to compile my css-s and js-s into myDir.

Finally i make a maven build.

With a hudson/jenkins build, you can easily do these in one job.

One improvement i can think of is to run npm via ant during maven build. I'll get back to you when i have a proof of concept of this.

//One extra hint: if you are developing under corporate environment and Windows7 you may have to add permissions to symbolic links for npm build. If you find errors in npm build, it worth a try: https://superuser.com/questions/104845/permission-to-make-symbolic-links-in-windows-7

Community
  • 1
  • 1
BlondCode
  • 4,009
  • 1
  • 19
  • 18
0

Since libsass-is-deprecated, and the fork bases on the same "archived lib": https://github.com/bit3/jsass ..bases on libsass...

How do I migrate? ... Someone might find this useful:

  1. [choco|brew|npm] install sass
    

    Source: https://sass-lang.com/install (I would not do it in , but we could!)

  2. With the "good ole" exec-maven-plugin, adopted from Spring Petclinic (site|repo) (previously extracting -, originally they used that same libsass-maven-plugin):

    <profile>
      <id>css</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.0.0</version> 
            <executions>
              <execution>
                <!-- process-resources > genererate-resources (i.e. later)-->
                <phase>process-resources</phase>
              </execution>
            </executions>
            <configuration>
              <!-- must be in $PATH !! -->
              <executable>sass</executable>
              <!-- it is quite silent, when everything works well -->
              <useMavenLogger>true</useMavenLogger>
              <arguments>
                <!-- additional sass path(s), adjust to our suits -->
                <argument>--load-path=${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/</argument>
                <argument>--no-source-map</argument>
                <argument>--verbose</argument>
                <argument>--trace</argument>
                <!-- for more args, see https://stackoverflow.com/a/70228043/592355 // `sass` -->
                <argument>${basedir}/src/main/scss/my.scss</argument>
                <argument>/path/to/my/dest/my.css</argument>
              </arguments>
              <!-- more config, when we like ... -->
            </configuration>
          </plugin>
          <!-- this is not part of the answer, but unpacks us required scss: -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack</id>
                <!-- genererate-resources < process-resources  (i.e. prior)-->
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.webjars.npm</groupId>
                      <artifactId>bootstrap</artifactId>
                      <version>${webjars-bootstrap.version}</version>
                    </artifactItem>
                  </artifactItems>
                  <outputDirectory>${project.build.directory}/webjars</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    
  3. Finally:

    mvn process-resources -Pcss
    

    (assuming no tests, no clean, no compile, "it is quite silent, when everything works well")

xerx593
  • 12,237
  • 5
  • 33
  • 64