diff --git a/src/com/qy/ui/AppMain.java b/src/com/qy/ui/AppMain.java index 6d71b63..39feb72 100755 --- a/src/com/qy/ui/AppMain.java +++ b/src/com/qy/ui/AppMain.java @@ -146,6 +146,8 @@ public class AppMain extends JFrame { new File(path).renameTo(new File(savePath)); } }); + }else if(model.equals("sdk")){ + new AutoPackageSDK(path -> new File(path).renameTo(new File(savePath)), version, packageName); } } diff --git a/src/com/qy/utils/AutoPackageSDK.java b/src/com/qy/utils/AutoPackageSDK.java index a04c03f..a8fceb7 100644 --- a/src/com/qy/utils/AutoPackageSDK.java +++ b/src/com/qy/utils/AutoPackageSDK.java @@ -35,6 +35,7 @@ public class AutoPackageSDK { } private void init() { + System.out.println("准备打包"); File gdtPath = new File("input" + File.separator + "gdtSDK" + File.separator); File unplayPath = new File("input" + File.separator + "uniplaySDK" + File.separator); File qysdkPath = new File("input" + File.separator + "qySDK" + File.separator); @@ -102,10 +103,11 @@ public class AutoPackageSDK { sdk.mkdirs(); } - + System.out.println("复制资源文件"); outAssetsQY(0, "0"); outAssetsQY(1, "4"); outRes(); + System.out.println("开始打包"); new AutoRandomAdSDK(array, new SmaliApkToolsPath() { @Override public void smaliPath(String path) { diff --git a/src/com/qy/utils/AutoPackageSDKMust.java b/src/com/qy/utils/AutoPackageSDKMust.java index e75de8d..0774182 100644 --- a/src/com/qy/utils/AutoPackageSDKMust.java +++ b/src/com/qy/utils/AutoPackageSDKMust.java @@ -53,15 +53,18 @@ public class AutoPackageSDKMust { Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "settings.gradle", sdk_src.getAbsolutePath() + File.separator, true); Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "local.properties", sdk_src.getAbsolutePath() + File.separator, true); try { + Runtime.getRuntime().exec("chmod 777 "+sdk_src.getAbsolutePath() + File.separator+"gradlew"); BufferedReader reader; - Process process = Runtime.getRuntime().exec("xcopy " + sdkPath.getAbsolutePath() + File.separator + "gradle " + sdk_src.getAbsolutePath() + File.separator + "gradle /E /I /Y"); + Tools.copy_dir(sdkPath.getAbsolutePath()+File.separator+"gradle",sdk_src.getAbsolutePath()+File.separator+"gradle"); + /*Process process = Runtime.getRuntime().exec("xcopy " + sdkPath.getAbsolutePath() + File.separator + "gradle " + sdk_src.getAbsolutePath() + File.separator + "gradle /E /I /Y"); reader = new BufferedReader(new InputStreamReader(process.getInputStream())); while (reader.readLine() != null) ; - reader.close(); - process = Runtime.getRuntime().exec("xcopy " + sdkPath.getAbsolutePath() + File.separator + "sdk " + sdk_src.getAbsolutePath() + File.separator + "sdk /E /I /Y"); + reader.close();*/ + Tools.copy_dir(sdkPath.getAbsolutePath()+File.separator+"sdk",sdk_src.getAbsolutePath()+File.separator+File.separator+"sdk"); + /* process = Runtime.getRuntime().exec("xcopy " + sdkPath.getAbsolutePath() + File.separator + "sdk " + sdk_src.getAbsolutePath() + File.separator + "sdk /E /I /Y"); reader = new BufferedReader(new InputStreamReader(process.getInputStream())); while (reader.readLine() != null) ; - reader.close(); + reader.close();*/ } catch (Exception e) { e.printStackTrace(); } @@ -185,14 +188,18 @@ public class AutoPackageSDKMust { private String packageSDK() { File sdk_src = new File("sdk_src"); try { - Process process = Runtime.getRuntime().exec(sdk_src.getAbsolutePath() + File.separator + "gradlew.bat assembleRelease -p " + sdk_src.getAbsolutePath() + File.separator + "sdk");//打包sdk + String gradlew=Tools.isWindowsRuntime()?"gradlew.bat":"gradlew"; + String exec=sdk_src.getAbsolutePath() + File.separator + gradlew +" assembleRelease -p " + sdk_src.getAbsolutePath() + File.separator + "sdk"; + System.out.println("exec="+exec); + Process process = Runtime.getRuntime().exec(exec);//打包sdk + Tools.outError(process.getErrorStream()); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String tmp; while ((tmp = reader.readLine()) != null) { System.out.println(tmp); } - process.waitFor(); reader.close(); + System.out.println("over"); return sdk_src.getAbsolutePath() + File.separator + "sdk" + File.separator + "build" + File.separator + "intermediates" + File.separator + "aar_main_jar" + File.separator + "release" + File.separator + "classes.jar"; } catch (Exception e) { @@ -201,6 +208,7 @@ public class AutoPackageSDKMust { return null; } + public static void main(String[] args) { start("eZMpiVponpIUV5VO", new SmaliApkToolsPath() { @Override diff --git a/src/com/qy/utils/Tools.java b/src/com/qy/utils/Tools.java index a63a8cd..3644973 100755 --- a/src/com/qy/utils/Tools.java +++ b/src/com/qy/utils/Tools.java @@ -69,7 +69,7 @@ public class Tools { // 目标文件所在目录不存在 if (!destFile.mkdirs()) { // 复制文件失败:创建目标文件所在目录失败 - System.err.println("创建文件夹失败"); + System.err.println("创建文件夹失败:"+destFile.getAbsolutePath()); return false; } @@ -122,6 +122,22 @@ public class Tools { return copyFileToName(srcFileName, destFileName, null, overlay); } } + public static void copy_dir(String src,String desc){ + try { + File dirSrc=new File(src); + for (File file : dirSrc.listFiles()) { + if(file.isDirectory()){ + new File(desc+File.separator+file.getName()).mkdirs(); + copy_dir(file.getAbsolutePath(),desc+File.separator+file.getName()); + }else{ + copyFile(file.getAbsolutePath(),desc,true); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + + } private static boolean copyDir(String dir,String dest){ try{ //System.out.println("复制文件"+dir+"到"+dest); @@ -312,4 +328,20 @@ public class Tools { e.printStackTrace(); } } + public static void outError(InputStream inputStream){ + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + String tmp; + while ((tmp = reader.readLine()) != null) { + System.out.println(tmp); + } + reader.close(); + }catch (Exception e){ + e.printStackTrace(); + } + } + public static boolean isWindowsRuntime(){ + System.out.println(System.getProperties().getProperty("os.name")); + return System.getProperties().getProperty("os.name").toLowerCase().contains("windows"); + } }