1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package nl.geodienstencentrum.maven.plugin.sass.compiler;
21
22 import nl.geodienstencentrum.maven.plugin.sass.AbstractSassMojo;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.plugins.annotations.Mojo;
27
28
29
30
31 @Mojo(name = "watch", threadSafe = true)
32 public class WatchMojo extends AbstractSassMojo {
33
34
35 private static final boolean IS_WINDOWS =
36 System.getProperty("os.name").toLowerCase().contains("win");
37
38
39
40
41
42
43
44
45
46 @Override
47 public void execute() throws MojoExecutionException, MojoFailureException {
48 if (this.isSkip()) {
49 return;
50 }
51 this.getLog().info("Watching Sass Templates");
52
53
54 final StringBuilder sassBuilder = new StringBuilder();
55 this.buildBasicSassScript(sassBuilder);
56 if (IS_WINDOWS) {
57 sassBuilder.append("require 'sass-listen'\nSass::Plugin.options.merge!(:poll => true)\n");
58 }
59 sassBuilder.append("Sass::Plugin.watch");
60 final String sassScript = sassBuilder.toString();
61
62
63 this.executeSassScript(sassScript);
64 }
65 }