1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.owasp.dependencycheck.maven;
19
20 import java.util.Locale;
21 import org.apache.maven.plugin.MojoExecutionException;
22 import org.apache.maven.plugin.MojoFailureException;
23 import org.apache.maven.plugins.annotations.LifecyclePhase;
24 import org.apache.maven.plugins.annotations.Mojo;
25 import org.apache.maven.plugins.annotations.ResolutionScope;
26 import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
27 import org.owasp.dependencycheck.utils.Settings;
28
29
30
31
32
33
34 @Mojo(
35 name = "update-only",
36 defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
37 threadSafe = false,
38 requiresDependencyResolution = ResolutionScope.NONE,
39 requiresOnline = true
40 )
41 public class UpdateMojo extends BaseDependencyCheckMojo {
42
43
44
45
46
47
48 @Override
49 public boolean canGenerateReport() {
50 return false;
51 }
52
53
54
55
56
57
58
59 @Override
60 public void runCheck() throws MojoExecutionException, MojoFailureException {
61 final Engine engine;
62 try {
63 engine = initializeEngine();
64 engine.update();
65 } catch (DatabaseException ex) {
66 if (getLog().isDebugEnabled()) {
67 getLog().debug("Database connection error", ex);
68 }
69 throw new MojoExecutionException("An exception occured connecting to the local database. Please see the log file for more details.", ex);
70 }
71 engine.cleanup();
72 Settings.cleanup();
73 }
74
75
76
77
78
79
80
81 @Override
82 public String getName(Locale locale) {
83 return "dependency-check-update";
84 }
85
86
87
88
89
90
91
92 @Override
93 public String getDescription(Locale locale) {
94 return "Updates the local cache of the NVD data from NIST.";
95 }
96
97 }