1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.google.code.sbt;
19
20 import java.io.File;
21 import java.io.IOException;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.apache.maven.artifact.Artifact;
27 import org.apache.maven.plugin.MojoExecutionException;
28 import org.apache.maven.plugin.MojoFailureException;
29 import org.apache.maven.plugins.annotations.LifecyclePhase;
30 import org.apache.maven.plugins.annotations.Mojo;
31 import org.apache.maven.plugins.annotations.Parameter;
32 import org.apache.maven.plugins.annotations.ResolutionScope;
33 import org.apache.maven.project.MavenProject;
34
35
36
37
38
39
40
41 @Mojo( name = "compile", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE )
42 public class SBTCompileMojo
43 extends AbstractSBTCompileMojo
44 {
45
46
47
48 @Parameter( defaultValue = "${project.compileSourceRoots}", readonly = true, required = true )
49 private List<String> compileSourceRoots;
50
51
52
53
54 @Parameter( defaultValue = "${project.compileClasspathElements}", readonly = true, required = true )
55 private List<String> classpathElements;
56
57
58
59
60 @Parameter( defaultValue = "${project.build.outputDirectory}", required = true, readonly = true )
61 private File outputDirectory;
62
63
64
65
66 @Parameter( defaultValue = "${project.artifact}", readonly = true, required = true )
67 private Artifact projectArtifact;
68
69 @Override
70 protected void internalExecute()
71 throws MojoExecutionException, MojoFailureException, IOException
72 {
73 super.internalExecute();
74
75 if ( outputDirectory.isDirectory() )
76 {
77 projectArtifact.setFile( outputDirectory );
78 }
79 }
80
81 @Override
82 protected List<String> getCompileSourceRoots()
83 {
84 return compileSourceRoots;
85 }
86
87 @Override
88 protected List<String> getClasspathElements()
89 {
90 return classpathElements;
91 }
92
93 @Override
94 protected File getOutputDirectory()
95 {
96 return outputDirectory;
97 }
98
99 @Override
100 protected File getAnalysisCacheFile()
101 {
102 return defaultAnalysisCacheFile( project );
103 }
104
105 @Override
106 protected Map<File, File> getAnalysisCacheMap()
107 {
108 HashMap<File, File> map = new HashMap<File, File>();
109 for ( MavenProject reactorProject : reactorProjects )
110 {
111 if ( reactorProject != project )
112 {
113 File analysisCacheFile = defaultAnalysisCacheFile( reactorProject );
114 if ( analysisCacheFile.isFile() )
115 {
116 File reactorProjectArtifactFile = reactorProject.getArtifact().getFile();
117 if ( reactorProjectArtifactFile != null )
118 {
119 map.put( reactorProjectArtifactFile.getAbsoluteFile(), analysisCacheFile.getAbsoluteFile() );
120 }
121 }
122 }
123 }
124 return map;
125 }
126
127 }