@@ -51,13 +51,6 @@ public class Installer {
5151 private static String openCvVersion = "" ;
5252 private static String version = "" ;
5353
54- private enum ArtifactType {
55- JAVA , // This one has special cases because the jar isn't packaged, so unzipping it would just output a ton of class files
56- JNI ,
57- HEADERS ,
58- NATIVES
59- }
60-
6154
6255 /**
6356 * Main entry point.
@@ -87,7 +80,7 @@ public static void main(String[] args) throws ParseException {
8780 if (parsedArgs .hasOption ("platform" )) {
8881 setPlatform (Platform .valueOf (parsedArgs .getOptionValue ("platform" )));
8982 }
90- setVersion (parsedArgs .getOptionValue ("version" ));
83+ setOpenCvVersion (parsedArgs .getOptionValue ("version" ));
9184 overwrite = parsedArgs .hasOption ("overwrite" );
9285 System .out .println ("Installing specified OpenCV components" );
9386 if (parsedArgs .hasOption ("java" ) || parsedArgs .hasOption ("all" )) {
@@ -127,7 +120,7 @@ public static void setPlatform(Platform p) {
127120 *
128121 * @param v the version of OpenCV to install
129122 */
130- public static void setVersion (String v ) {
123+ public static void setOpenCvVersion (String v ) {
131124 openCvVersion = v ;
132125 calculateVersion ();
133126 }
@@ -136,6 +129,15 @@ private static void calculateVersion() {
136129 version = platform + "-" + openCvVersion ;
137130 }
138131
132+ /**
133+ * Gets the version of OpenCV being installed.
134+ *
135+ * @return the version of OpenCV being installed
136+ */
137+ public static String getOpenCvVersion () {
138+ return openCvVersion ;
139+ }
140+
139141 /**
140142 * Downloads the Java API jar.
141143 */
@@ -177,6 +179,12 @@ public static void installNatives() {
177179 }
178180
179181 private static void install (ArtifactType type ) {
182+ if (!overridePlatform && InstallChecker .isInstalled (type , openCvVersion )) {
183+ System .out .println ("Artifacts for the version " + openCvVersion + " " + type .getArtifactName () + " have already been installed!" );
184+ if (!overwrite ) {
185+ return ;
186+ }
187+ }
180188 try {
181189 String artifactId ;
182190 String v = version ;
@@ -231,6 +239,7 @@ private static void install(ArtifactType type) {
231239 unzipped = dst .getParent ();
232240 }
233241 copyAll (unzipped , Paths .get (installLocation ));
242+ InstallChecker .registerSuccessfulInstall (type , openCvVersion );
234243 } catch (Exception e ) {
235244 e .printStackTrace (System .out );
236245 }
@@ -252,6 +261,7 @@ private static String resolveRelative(String repo, String artifactId, String ver
252261 * Unzips the given zip file
253262 *
254263 * @param zipFile the file to unzip
264+ *
255265 * @return the directory that the file was unzipped into
256266 */
257267 private static Path unzip (File zipFile ) {
@@ -282,6 +292,7 @@ private static Path unzip(File zipFile) {
282292 *
283293 * @param sourceDir the directory holding the files to copy
284294 * @param dstDir the directory to copy the files into
295+ *
285296 * @throws IOException if the source directory is unreadable
286297 */
287298 private static void copyAll (Path sourceDir , Path dstDir ) throws IOException {
0 commit comments