This commit is contained in:
Yutousama 2020-06-18 15:26:26 +08:00
parent d24ba2e3e4
commit bddb4d1243
4 changed files with 52 additions and 8 deletions

View File

@ -146,6 +146,8 @@ public class AppMain extends JFrame {
new File(path).renameTo(new File(savePath)); new File(path).renameTo(new File(savePath));
} }
}); });
}else if(model.equals("sdk")){
new AutoPackageSDK(path -> new File(path).renameTo(new File(savePath)), version, packageName);
} }
} }

View File

@ -35,6 +35,7 @@ public class AutoPackageSDK {
} }
private void init() { private void init() {
System.out.println("准备打包");
File gdtPath = new File("input" + File.separator + "gdtSDK" + File.separator); File gdtPath = new File("input" + File.separator + "gdtSDK" + File.separator);
File unplayPath = new File("input" + File.separator + "uniplaySDK" + File.separator); File unplayPath = new File("input" + File.separator + "uniplaySDK" + File.separator);
File qysdkPath = new File("input" + File.separator + "qySDK" + File.separator); File qysdkPath = new File("input" + File.separator + "qySDK" + File.separator);
@ -102,10 +103,11 @@ public class AutoPackageSDK {
sdk.mkdirs(); sdk.mkdirs();
} }
System.out.println("复制资源文件");
outAssetsQY(0, "0"); outAssetsQY(0, "0");
outAssetsQY(1, "4"); outAssetsQY(1, "4");
outRes(); outRes();
System.out.println("开始打包");
new AutoRandomAdSDK(array, new SmaliApkToolsPath() { new AutoRandomAdSDK(array, new SmaliApkToolsPath() {
@Override @Override
public void smaliPath(String path) { public void smaliPath(String path) {

View File

@ -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 + "settings.gradle", sdk_src.getAbsolutePath() + File.separator, true);
Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "local.properties", sdk_src.getAbsolutePath() + File.separator, true); Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "local.properties", sdk_src.getAbsolutePath() + File.separator, true);
try { try {
Runtime.getRuntime().exec("chmod 777 "+sdk_src.getAbsolutePath() + File.separator+"gradlew");
BufferedReader reader; 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())); reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
while (reader.readLine() != null) ; while (reader.readLine() != null) ;
reader.close(); reader.close();*/
process = Runtime.getRuntime().exec("xcopy " + sdkPath.getAbsolutePath() + File.separator + "sdk " + sdk_src.getAbsolutePath() + File.separator + "sdk /E /I /Y"); 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())); reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
while (reader.readLine() != null) ; while (reader.readLine() != null) ;
reader.close(); reader.close();*/
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -185,14 +188,18 @@ public class AutoPackageSDKMust {
private String packageSDK() { private String packageSDK() {
File sdk_src = new File("sdk_src"); File sdk_src = new File("sdk_src");
try { 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())); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String tmp; String tmp;
while ((tmp = reader.readLine()) != null) { while ((tmp = reader.readLine()) != null) {
System.out.println(tmp); System.out.println(tmp);
} }
process.waitFor();
reader.close(); reader.close();
System.out.println("over");
return sdk_src.getAbsolutePath() + File.separator + "sdk" + File.separator + "build" + File.separator 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"; + "intermediates" + File.separator + "aar_main_jar" + File.separator + "release" + File.separator + "classes.jar";
} catch (Exception e) { } catch (Exception e) {
@ -201,6 +208,7 @@ public class AutoPackageSDKMust {
return null; return null;
} }
public static void main(String[] args) { public static void main(String[] args) {
start("eZMpiVponpIUV5VO", new SmaliApkToolsPath() { start("eZMpiVponpIUV5VO", new SmaliApkToolsPath() {
@Override @Override

View File

@ -69,7 +69,7 @@ public class Tools {
// 目标文件所在目录不存在 // 目标文件所在目录不存在
if (!destFile.mkdirs()) { if (!destFile.mkdirs()) {
// 复制文件失败创建目标文件所在目录失败 // 复制文件失败创建目标文件所在目录失败
System.err.println("创建文件夹失败"); System.err.println("创建文件夹失败:"+destFile.getAbsolutePath());
return false; return false;
} }
@ -122,6 +122,22 @@ public class Tools {
return copyFileToName(srcFileName, destFileName, null, overlay); 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){ private static boolean copyDir(String dir,String dest){
try{ try{
//System.out.println("复制文件"+dir+""+dest); //System.out.println("复制文件"+dir+""+dest);
@ -312,4 +328,20 @@ public class Tools {
e.printStackTrace(); 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");
}
} }