@@ -40,7 +40,8 @@ public class Installer {
4040 }
4141 }
4242
43- private static final Platform platform = PlatformDetector .getPlatform ();
43+ private static Platform platform = PlatformDetector .getPlatform ();
44+ private static boolean overridePlatform = false ;
4445 private static final String groupId = "org.opencv" ;
4546 private static final String javaJarName = "opencv-java" ;
4647 private static final String jniName = "opencv-jni" ;
@@ -68,6 +69,7 @@ public static void main(String... args) throws ParseException {
6869 addOption ("a" , "all" , false , "Installs all artifacts" );
6970 addOption ("v" , "version" , true , "Set the version of OpenCV to install" );
7071 addOption (null , "no-overwrite" , false , "Don't overwrite existing files when installing" );
72+ addOption (null , "platform" , true , "Install artifacts for a specific platform" );
7173 }};
7274 CommandLine parsedArgs = p .parse (options , args );
7375 if (parsedArgs .hasOption ("help" )) {
@@ -78,6 +80,10 @@ public static void main(String... args) throws ParseException {
7880 if (!parsedArgs .hasOption ("version" )) {
7981 throw new MissingOptionException ("-v <version>" );
8082 }
83+ if (parsedArgs .hasOption ("platform" )) {
84+ overridePlatform = true ;
85+ platform = Platform .valueOf (parsedArgs .getOptionValue ("platform" ));
86+ }
8187 openCvVersion = parsedArgs .getOptionValue ("version" );
8288 version = platform + "-" + openCvVersion ;
8389 overwrite = !parsedArgs .hasOption ("no-overwrite" );
@@ -124,24 +130,27 @@ private static void install(ArtifactType type) {
124130 try {
125131 String artifactId ;
126132 String v = version ;
127- String installLocation ;
133+ String installLocation = "" ;
134+ if (overridePlatform ) {
135+ installLocation = "install" ;
136+ }
128137 switch (type ) {
129138 case JAVA :
130139 artifactId = javaJarName ;
131140 v = openCvVersion ;
132- installLocation = platform .getJavaInstallLocation ();
141+ installLocation + = platform .getJavaInstallLocation ();
133142 break ;
134143 case JNI :
135144 artifactId = jniName ;
136- installLocation = platform .getJniInstallLocation ();
145+ installLocation + = platform .getJniInstallLocation ();
137146 break ;
138147 case HEADERS :
139148 artifactId = headersName ;
140- installLocation = platform .getHeadersInstallLocation ();
149+ installLocation + = platform .getHeadersInstallLocation ();
141150 break ;
142151 case NATIVES :
143152 artifactId = nativesName ;
144- installLocation = platform .getNativesInstallLocation ();
153+ installLocation + = platform .getNativesInstallLocation ();
145154 break ;
146155 default :
147156 throw new UnsupportedOperationException ("Unknown artifact type: " + type );
0 commit comments