1 package org.scala_tools.maven;
2
3 import java.io.File;
4
5 import org.apache.maven.plugin.AbstractMojo;
6 import org.apache.maven.plugin.MojoExecutionException;
7 import org.apache.maven.project.MavenProject;
8
9
10
11
12
13
14
15
16
17 public class AddSourceMojo extends AbstractMojo {
18
19
20
21
22
23
24 private MavenProject project;
25
26
27
28
29 protected File sourceDir;
30
31
32
33
34 protected File testSourceDir;
35
36 public void execute() throws MojoExecutionException {
37 try {
38 if (sourceDir != null) {
39 String path = sourceDir.getCanonicalPath();
40 if (!project.getCompileSourceRoots().contains(path)) {
41 getLog().info("Add Source directory: " + path);
42 project.addCompileSourceRoot(path);
43 }
44 }
45 if (testSourceDir != null) {
46 String path = testSourceDir.getCanonicalPath();
47 if (!project.getTestCompileSourceRoots().contains(path)) {
48 getLog().info("Add Test Source directory: " + path);
49 project.addCompileSourceRoot(path);
50 }
51 }
52 } catch(Exception exc) {
53 getLog().warn(exc);
54 }
55 }
56 }