7
7
import java .nio .file .StandardCopyOption ;
8
8
import java .util .List ;
9
9
10
+ import javax .annotation .Nullable ;
11
+
10
12
import org .gradle .api .Plugin ;
11
13
import org .gradle .api .Project ;
12
14
import org .gradle .api .tasks .JavaExec ;
13
15
14
- import javax .annotation .Nullable ;
15
-
16
16
public class HeoPlugin implements Plugin <Project > {
17
17
18
18
private static final String REPORT_PATH = "build/reports/heo" ;
19
19
20
20
@ Override
21
21
public void apply (Project project ) {
22
- final HeoConfig config = project .getExtensions ().create ("heo" , HeoConfig .class );
22
+ final HeoPluginConfig config = project .getExtensions ().create ("heo" , HeoPluginConfig .class );
23
23
project .getTasks ().register ("heoReport" , JavaExec .class , task -> {
24
24
task .setGroup ("heo" );
25
25
task .setDescription ("Execute heo-cli" );
@@ -37,24 +37,33 @@ public void apply(Project project) {
37
37
38
38
task .setMain ("-jar" );
39
39
task .args (tempJar .getAbsolutePath ());
40
- task .args (List .of ("-d" , determineDirectory (project , config .getDirectoryPath ()),
41
- "-p" , determinePrefixPackage (project , config .getPrefixPackage ()),
42
- "-o" , determineDestination (project , config .getDestination ())));
40
+ task .args (List .of (
41
+ "-d" , determineDirectory (project , config .getDirectoryPath ()),
42
+ "-p" , determinePrefixPackage (project , config .getPrefixPackage ()),
43
+ "-o" , determineDestination (project , config .getDestination ()),
44
+ "--failure-on-cycles" , config .isFailureOnCycles ()
45
+ ));
43
46
44
47
tempJar .deleteOnExit ();
45
48
});
46
49
}
47
50
48
51
private static String determineDirectory (Project project , @ Nullable String directoryPath ) {
49
- return StringUtils .isBlank (directoryPath ) ? project .getProjectDir ().getAbsolutePath () : directoryPath ;
52
+ return StringUtils .isBlank (directoryPath )
53
+ ? project .getProjectDir ().getAbsolutePath ()
54
+ : directoryPath ;
50
55
}
51
56
52
57
private static String determinePrefixPackage (Project project , @ Nullable String prefixPackage ) {
53
- return StringUtils .isBlank (prefixPackage ) ? project .getGroup ().toString () : prefixPackage ;
58
+ return StringUtils .isBlank (prefixPackage )
59
+ ? project .getGroup ().toString ()
60
+ : prefixPackage ;
54
61
}
55
62
56
63
private static String determineDestination (Project project , @ Nullable String destination ) {
57
- return StringUtils .isBlank (destination ) ? Path .of (project .getProjectDir ().getAbsolutePath (), REPORT_PATH , "index.png" ).toString () : destination ;
64
+ return StringUtils .isBlank (destination )
65
+ ? Path .of (project .getProjectDir ().getAbsolutePath (), REPORT_PATH , "index.png" ).toString ()
66
+ : destination ;
58
67
}
59
68
60
69
}
0 commit comments