需求:

把unity打成aar并上传到maven库

其实就是把前两个博客整合了一下

unity打aar包工具

aar上传maven库工具

这里先说eclipse版的

  1. package com.jinkejoy.build_aar;
  2.  
  3. import java.awt.FlowLayout;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.io.File;
  7. import java.io.FileNotFoundException;
  8. import java.io.IOException;
  9. import java.io.RandomAccessFile;
  10.  
  11. import javax.swing.JButton;
  12. import javax.swing.JFileChooser;
  13. import javax.swing.JFrame;
  14. import javax.swing.JLabel;
  15. import javax.swing.JOptionPane;
  16. import javax.swing.JTextField;
  17.  
  18. public class EcAarBuildUpload {
  19. private static final String BUILD_PROJECT_PATH = "./aar-build";
  20. private static final String UPLOAD_PROJECT_PATH = "./aar-upload";
  21.  
  22. private JFrame jFrame;
  23.  
  24. private JTextField sourceText;
  25. private JButton sourceButton;
  26. private File sourceFile;
  27.  
  28. private JTextField sdkText;
  29. private JButton sdkButton;
  30. private File sdkFile;
  31.  
  32. private JTextField ndkText;
  33. private JButton ndkButton;
  34. private File ndkFile;
  35.  
  36. private JTextField groupIdText;
  37. private JTextField aarNameText;
  38. private JTextField versionText;
  39.  
  40. private JButton buildButton;
  41. private JButton uploadButton;
  42.  
  43. public static void main(String[] args) {
  44. new EcAarBuildUpload();
  45. }
  46.  
  47. public EcAarBuildUpload() {
  48. openFileWindow();
  49. }
  50.  
  51. private void openFileWindow() {
  52. jFrame = new JFrame();
  53. jFrame.setTitle("将android工程打成aar并上传到maven库");
  54. jFrame.setBounds(500, 500, 700, 250);
  55. jFrame.setVisible(true);
  56. FlowLayout layout = new FlowLayout();
  57. layout.setAlignment(FlowLayout.LEFT);
  58. //选择文件
  59. JLabel sourceLabel = new JLabel("工程路径:");
  60. sourceText = new JTextField(50);
  61. sourceButton = new JButton("浏览");
  62. //输出路径
  63. JLabel sdkLabel = new JLabel("本地sdk路径:");
  64. sdkText = new JTextField(48);
  65. sdkButton = new JButton("浏览");
  66. //sdk
  67. JLabel ndkLabel = new JLabel("本地ndk路径:");
  68. ndkText = new JTextField(48);
  69. ndkButton = new JButton("浏览");
  70. //上传aar
  71. JLabel groupIdLabel = new JLabel("aar前缀包名:");
  72. groupIdText = new JTextField(54);
  73. JLabel aarNameLabel = new JLabel("aar名称:");
  74. aarNameText = new JTextField(56);
  75. JLabel versionLabel = new JLabel("aar版本号:");
  76. versionText = new JTextField(55);
  77. buildButton = new JButton("构建aar");
  78. uploadButton = new JButton("上传aar");
  79.  
  80. jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  81. jFrame.setLayout(layout);
  82. jFrame.setResizable(false);
  83. jFrame.add(sourceLabel);
  84. jFrame.add(sourceText);
  85. jFrame.add(sourceButton);
  86. jFrame.add(sdkLabel);
  87. jFrame.add(sdkText);
  88. jFrame.add(sdkButton);
  89. jFrame.add(ndkLabel);
  90. jFrame.add(ndkText);
  91. jFrame.add(ndkButton);
  92. jFrame.add(groupIdLabel);
  93. jFrame.add(groupIdText);
  94. jFrame.add(aarNameLabel);
  95. jFrame.add(aarNameText);
  96. jFrame.add(versionLabel);
  97. jFrame.add(versionText);
  98. jFrame.add(buildButton);
  99. jFrame.add(uploadButton);
  100.  
  101. chooseSourceFile();
  102. chooseSdkFile();
  103. chooseNdkFile();
  104.  
  105. buildAarButton();
  106. uploadAarButton();
  107.  
  108. getCacheInput();
  109. }
  110.  
  111. private void getCacheInput() {
  112. sourceText.setText(CacheUtils.getCacheInput("sourcePath"));
  113. sdkText.setText(CacheUtils.getCacheInput("sdkPath"));
  114. ndkText.setText(CacheUtils.getCacheInput("ndkPath"));
  115. groupIdText.setText(CacheUtils.getCacheInput("groupId"));
  116. aarNameText.setText(CacheUtils.getCacheInput("aarName"));
  117. versionText.setText(CacheUtils.getCacheInput("version"));
  118. }
  119.  
  120. private void buildAar() {
  121. if (checkInput()) return;
  122. CacheUtils.cacheInput(sourceText, sdkText, ndkText, groupIdText, aarNameText, versionText);
  123. createAsFile();
  124. findUpdateFile(BUILD_PROJECT_PATH);
  125. gradleBuildAar();
  126. }
  127.  
  128. private void gradleBuildAar() {
  129. String command = "cmd /c start gradle clean assembleDebug";
  130. File cmdPath = new File(BUILD_PROJECT_PATH);
  131. Runtime runtime = Runtime.getRuntime();
  132. try {
  133. Process process = runtime.exec(command, null, cmdPath);
  134. } catch (IOException e) {
  135. e.printStackTrace();
  136. }
  137. }
  138.  
  139. private void findUpdateFile(String filePath) {
  140. File file = new File(filePath);
  141. if (!file.exists()) {
  142. return;
  143. }
  144. File[] files = file.listFiles();
  145. for (File updateFile : files) {
  146. if (updateFile.isDirectory()) {
  147. findUpdateFile(updateFile.getAbsolutePath());
  148. } else {
  149. switch (updateFile.getName().toString()) {
  150. case "build.gradle":
  151. updateBuildGradle(updateFile.getAbsolutePath());
  152. break;
  153. case "AndroidManifest.xml":
  154. updateManifestFile(updateFile.getAbsolutePath());
  155. break;
  156. case "local.properties":
  157. updateSdkFile(updateFile.getAbsolutePath());
  158. break;
  159. case "UnityPlayerActivity.java":
  160. case "UnityPlayerNativeActivity.java":
  161. case "UnityPlayerProxyActivity.java":
  162. updateFile.delete();
  163. break;
  164. }
  165. }
  166. }
  167. }
  168.  
  169. private void updateSdkFile(String filePath) {
  170. try {
  171. RandomAccessFile sdkFile = new RandomAccessFile(filePath, "rw");
  172. String line;
  173. long lastPoint = 0;
  174. while ((line = sdkFile.readLine()) != null) {
  175. final long point = sdkFile.getFilePointer();
  176. if (line.contains("sdk.dir")) {
  177. String s = line.substring(0);
  178. String sdkStr = sdkText.getText().toString();
  179. String sdkPan = sdkStr.substring(0, 1);
  180. sdkStr = sdkStr.substring(1).replace("\\", "\\\\");
  181. String ndkStr = sdkText.getText().toString();
  182. String ndkPan = ndkStr.substring(0, 1);
  183. ndkStr = ndkStr.substring(1).replace("\\", "\\\\");
  184. String replaceStr = "sdk.dir=" + sdkPan + "\\" + sdkStr + "\n" + "ndk.dir=" + ndkPan + "\\" + ndkStr + "\n ";
  185. String str = line.replace(s, replaceStr);
  186. sdkFile.seek(lastPoint);
  187. sdkFile.writeBytes(str);
  188. }
  189. lastPoint = point;
  190. }
  191. } catch (FileNotFoundException e) {
  192. e.printStackTrace();
  193. } catch (IOException e) {
  194. e.printStackTrace();
  195. }
  196. }
  197.  
  198. private void updateManifestFile(String filePath) {
  199. try {
  200. RandomAccessFile manifestFile = new RandomAccessFile(filePath, "rw");
  201. String line;
  202. long lastPoint = 0;
  203. while ((line = manifestFile.readLine()) != null) {
  204. final long ponit = manifestFile.getFilePointer();
  205. if (line.contains("<activity") && line.contains("UnityPlayerActivity") && !line.contains("<!--<activity")) {
  206. String str = line.replace("<activity", "<!--<activity");
  207. manifestFile.seek(lastPoint);
  208. manifestFile.writeBytes(str);
  209. }
  210. if (line.contains("</activity>") && !line.contains("</activity>-->")) {
  211. String str = line.replace("</activity>", "</activity>-->\n");
  212. manifestFile.seek(lastPoint);
  213. manifestFile.writeBytes(str);
  214. }
  215. lastPoint = ponit;
  216. }
  217. } catch (FileNotFoundException e) {
  218. e.printStackTrace();
  219. } catch (IOException e) {
  220. e.printStackTrace();
  221. }
  222. }
  223.  
  224. private void updateBuildGradle(String filePath) {
  225. try {
  226. RandomAccessFile buildGradleFile = new RandomAccessFile(filePath, "rw");
  227. String line;
  228. long lastPoint = 0;
  229. while ((line = buildGradleFile.readLine()) != null) {
  230. final long ponit = buildGradleFile.getFilePointer();
  231. if (line.contains("classpath 'com.android.tools.build:gradle")) {
  232. String s = line.substring(line.indexOf("classpath"));
  233. String str = line.replace(s, "classpath 'com.android.tools.build:gradle:2.3.0' \n");
  234. buildGradleFile.seek(lastPoint);
  235. buildGradleFile.writeBytes(str);
  236. }
  237. if (line.contains("com.android.application")) {
  238. String str = line.replace("'com.android.application'", "'com.android.library' \n");
  239. buildGradleFile.seek(lastPoint);
  240. buildGradleFile.writeBytes(str);
  241. }
  242. if (line.contains("compileSdkVersion") && !line.contains("compileSdkVersion 25")) {
  243. String s = line.substring(line.indexOf("compileSdkVersion")).toString();
  244. String str = line.replace(s, "compileSdkVersion 25\n");
  245. buildGradleFile.seek(lastPoint);
  246. buildGradleFile.writeBytes(str);
  247. }
  248. if (line.contains("buildToolsVersion") && !line.contains("buildToolsVersion '25.0.2'")) {
  249. String s = line.substring(line.indexOf("buildToolsVersion")).toString();
  250. String str = line.replace(s, "buildToolsVersion '25.0.2'\n");
  251. buildGradleFile.seek(lastPoint);
  252. buildGradleFile.writeBytes(str);
  253. }
  254. if (line.contains("targetSdkVersion") && !line.contains("targetSdkVersion 25")) {
  255. String s = line.substring(line.indexOf("targetSdkVersion")).toString();
  256. String str = line.replace(s, "targetSdkVersion 25\n");
  257. buildGradleFile.seek(lastPoint);
  258. buildGradleFile.writeBytes(str);
  259. }
  260. if (line.contains("applicationId") && !line.contains("//applicationId")) {
  261. String s = line.substring(line.indexOf("applicationId")).toString();
  262. String str = line.replace(s, "//" + s + "\n");
  263. buildGradleFile.seek(lastPoint);
  264. buildGradleFile.writeBytes(str);
  265. }
  266. lastPoint = ponit;
  267. }
  268. } catch (FileNotFoundException e) {
  269. e.printStackTrace();
  270. } catch (IOException e) {
  271. e.printStackTrace();
  272. }
  273. }
  274.  
  275. private void createAsFile() {
  276. String sourcePath = sourceText.getText().toString();
  277. File buildFile = new File(BUILD_PROJECT_PATH);
  278. String buildProject = buildFile.getAbsolutePath();
  279. //delete history
  280. String deletePath = buildProject + "\\app\\src\\main";
  281. FileUtils.delAllFile(deletePath);
  282. String buildPath1 = buildProject + "\\build";
  283. FileUtils.delFolder(buildPath1);
  284. String buildPath2 = buildProject + "\\app\\build";
  285. FileUtils.delFolder(buildPath2);
  286. //assets
  287. String assets = sourcePath + "\\assets";
  288. String newAssets = buildProject + "\\app\\src\\main\\assets";
  289. FileUtils.copyFolder(assets, newAssets);
  290. //unity-classes.jar
  291. String unity = sourcePath + "\\libs\\unity-classes.jar";
  292. String newUnity = buildProject + "\\app\\libs\\unity-classes.jar";
  293. FileUtils.copyFile(new File(unity), new File(newUnity));
  294. //libs
  295. String libs = sourcePath + "\\libs";
  296. String jniLibs = buildProject + "\\app\\src\\main\\jniLibs";
  297. FileUtils.copyFolder(libs, jniLibs);
  298. File jni_unity = new File(jniLibs + "\\unity-classes.jar");
  299. jni_unity.delete();
  300. //res
  301. String res = sourcePath + "\\res";
  302. String newRes = buildProject + "\\app\\src\\main\\res";
  303. FileUtils.copyFolder(res, newRes);
  304. //src
  305. String src = sourcePath + "\\src";
  306. String java = buildProject + "\\app\\src\\main\\java";
  307. FileUtils.copyFolder(src, java);
  308. //AndroidManifest.xml
  309. String manifest = sourcePath + "\\AndroidManifest.xml";
  310. String newManifest = buildProject + "\\app\\src\\main\\AndroidManifest.xml";
  311. FileUtils.copyFile(new File(manifest), new File(newManifest));
  312. }
  313.  
  314. private void uploadAar() {
  315. findAarFile(BUILD_PROJECT_PATH);
  316. gradleUpload();
  317. }
  318.  
  319. private void gradleUpload() {
  320. String command = "cmd /c start gradlew clean uploadArchives";
  321. File cmdPath = new File(UPLOAD_PROJECT_PATH);
  322. Runtime runtime = Runtime.getRuntime();
  323. try {
  324. Process process = runtime.exec(command, null, cmdPath);
  325. } catch (IOException e) {
  326. e.printStackTrace();
  327. }
  328. }
  329.  
  330. private void findAarFile(String filePath) {
  331. File file = new File(filePath);
  332. if (!file.exists()) {
  333. return;
  334. }
  335. File[] files = file.listFiles();
  336. for (File outputFile : files) {
  337. if (outputFile.isDirectory()) {
  338. findAarFile(outputFile.getAbsolutePath());
  339. } else {
  340. String fileName = outputFile.getName().toString();
  341. if (fileName.endsWith(".aar")) {
  342. File aarFile = new File("./" + fileName);
  343. FileUtils.copyFile(outputFile, aarFile);
  344. CacheUtils.cacheAar(aarFile.getAbsolutePath());
  345. }
  346. }
  347. }
  348. }
  349.  
  350. private boolean checkInput() {
  351. if ("".equals(sourceText.getText().toString())) {
  352. JOptionPane.showMessageDialog(jFrame, "请输入源工程文件路径");
  353. return true;
  354. }
  355. if ("".equals(sdkText.getText().toString())) {
  356. JOptionPane.showMessageDialog(jFrame, "请输入本地sdk路径");
  357. return true;
  358. }
  359. if ("".equals(ndkText.getText().toString())) {
  360. JOptionPane.showMessageDialog(jFrame, "请输入本地ndk路径");
  361. return true;
  362. }
  363. if ("".equals(groupIdText.getText().toString())) {
  364. JOptionPane.showMessageDialog(jFrame, "请输入aar前缀包名");
  365. return true;
  366. }
  367. if ("".equals(aarNameText.getText().toString())) {
  368. JOptionPane.showMessageDialog(jFrame, "请输入aar名称");
  369. return true;
  370. }
  371. if ("".equals(versionText.getText().toString())) {
  372. JOptionPane.showMessageDialog(jFrame, "请输入aar版本号");
  373. return true;
  374. }
  375. return false;
  376. }
  377.  
  378. private void buildAarButton() {
  379. buildButton.addActionListener(new ActionListener() {
  380. @Override
  381. public void actionPerformed(ActionEvent actionEvent) {
  382. buildAar();
  383. }
  384. });
  385. }
  386.  
  387. private void uploadAarButton() {
  388. uploadButton.addActionListener(new ActionListener() {
  389. @Override
  390. public void actionPerformed(ActionEvent actionEvent) {
  391. uploadAar();
  392. }
  393. });
  394. }
  395.  
  396. private void chooseSourceFile() {
  397. sourceButton.addActionListener(new ActionListener() {
  398. @Override
  399. public void actionPerformed(ActionEvent actionEvent) {
  400. JFileChooser chooser = new JFileChooser();
  401. chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  402. chooser.showDialog(new JLabel(), "选择");
  403. sourceFile = chooser.getSelectedFile();
  404. sourceText.setText(sourceFile.getAbsolutePath().toString());
  405. }
  406. });
  407. }
  408.  
  409. private void chooseSdkFile() {
  410. sdkButton.addActionListener(new ActionListener() {
  411. @Override
  412. public void actionPerformed(ActionEvent actionEvent) {
  413. JFileChooser chooser = new JFileChooser();
  414. chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  415. chooser.showDialog(new JLabel(), "选择");
  416. sdkFile = chooser.getSelectedFile();
  417. sdkText.setText(sdkFile.getAbsolutePath().toString());
  418. }
  419. });
  420. }
  421.  
  422. private void chooseNdkFile() {
  423. ndkButton.addActionListener(new ActionListener() {
  424. @Override
  425. public void actionPerformed(ActionEvent actionEvent) {
  426. JFileChooser chooser = new JFileChooser();
  427. chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  428. chooser.showDialog(new JLabel(), "选择");
  429. ndkFile = chooser.getSelectedFile();
  430. ndkText.setText(ndkFile.getAbsolutePath().toString());
  431. }
  432. });
  433. }
  434. }
  1. package com.jinkejoy.build_aar;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.util.Iterator;
  9. import java.util.Map;
  10. import java.util.Properties;
  11.  
  12. import javax.swing.JTextField;
  13.  
  14. public class CacheUtils {
  15. private static final String CACHE_PATH = "./cache-input.properties";
  16. private static final String AAR_PATH = "./aar-path.properties";
  17.  
  18. public static void cacheInput(JTextField sourceText, JTextField sdkText, JTextField ndkText,
  19. JTextField groupIdText, JTextField aarNameText, JTextField versionText) {
  20. String cache = "sourcePath=" + sourceText.getText().toString().replace("\\", "\\\\") + "\n" +
  21. "sdkPath=" + sdkText.getText().toString().replace("\\", "\\\\") + "\n" +
  22. "ndkPath=" + ndkText.getText().toString().replace("\\", "\\\\") + "\n" +
  23. "groupId=" + groupIdText.getText().toString().replace("\\", "\\\\") + "\n" +
  24. "aarName=" + aarNameText.getText().toString().replace("\\", "\\\\") + "\n" +
  25. "version=" + versionText.getText().toString().replace("\\", "\\\\");
  26. File cacheFile = new File(CACHE_PATH);
  27. if (!cacheFile.exists()) {
  28. try {
  29. cacheFile.createNewFile();
  30. } catch (IOException e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. try {
  35. FileOutputStream fop = new FileOutputStream(cacheFile);
  36. fop.write(cache.getBytes());
  37. fop.flush();
  38. fop.close();
  39. } catch (FileNotFoundException e) {
  40. e.printStackTrace();
  41. } catch (IOException e) {
  42. e.printStackTrace();
  43. }
  44. }
  45.  
  46. public static void cacheAar(String aarPath) {
  47. String cache = "aarPath=" + aarPath.replace("\\", "\\\\");
  48. File cacheFile = new File(AAR_PATH);
  49. if (!cacheFile.exists()) {
  50. try {
  51. cacheFile.createNewFile();
  52. } catch (IOException e) {
  53. e.printStackTrace();
  54. }
  55. }
  56. try {
  57. FileOutputStream fop = new FileOutputStream(cacheFile);
  58. fop.write(cache.getBytes());
  59. fop.flush();
  60. fop.close();
  61. } catch (FileNotFoundException e) {
  62. e.printStackTrace();
  63. } catch (IOException e) {
  64. e.printStackTrace();
  65. }
  66. }
  67.  
  68. public static String getCacheInput(String key) {
  69. File cacheFile = new File(CACHE_PATH);
  70. if (cacheFile.exists()) {
  71. try {
  72. FileInputStream fip = new FileInputStream(cacheFile);
  73. Properties properties = new Properties();
  74. properties.load(fip);
  75. Iterator<Map.Entry<Object, Object>> iterator = properties.entrySet().iterator();
  76. while (iterator.hasNext()) {
  77. Map.Entry<Object, Object> entry = iterator.next();
  78. if (key.equals(entry.getKey().toString())) {
  79. return entry.getValue().toString();
  80. }
  81. }
  82. } catch (FileNotFoundException e) {
  83. e.printStackTrace();
  84. } catch (IOException e) {
  85. e.printStackTrace();
  86. }
  87. }
  88. return "";
  89. }
  90. }
  1. package com.jinkejoy.build_aar;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.nio.channels.FileChannel;
  9.  
  10. public class FileUtils {
  11. public static boolean delAllFile(String path) {
  12. boolean flag = false;
  13. File file = new File(path);
  14. if (!file.exists()) {
  15. return flag;
  16. }
  17. if (!file.isDirectory()) {
  18. return flag;
  19. }
  20. String[] tempList = file.list();
  21. File temp = null;
  22. for (int i = 0; i < tempList.length; i++) {
  23. if (path.endsWith(File.separator)) {
  24. temp = new File(path + tempList[i]);
  25. } else {
  26. temp = new File(path + File.separator + tempList[i]);
  27. }
  28. if (temp.isFile()) {
  29. temp.delete();
  30. }
  31. if (temp.isDirectory()) {
  32. delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
  33. delFolder(path + "/" + tempList[i]);//再删除空文件夹
  34. flag = true;
  35. }
  36. }
  37. return flag;
  38. }
  39.  
  40. public static void delFolder(String folderPath) {
  41. try {
  42. delAllFile(folderPath); //删除完里面所有内容
  43. String filePath = folderPath;
  44. filePath = filePath.toString();
  45. java.io.File myFilePath = new java.io.File(filePath);
  46. myFilePath.delete(); //删除空文件夹
  47. } catch (Exception e) {
  48. e.printStackTrace();
  49. }
  50. }
  51.  
  52. public static void copyFile(File source, File dest) {
  53. FileChannel inputChannel = null;
  54. FileChannel outputChannel = null;
  55. try {
  56. inputChannel = new FileInputStream(source).getChannel();
  57. outputChannel = new FileOutputStream(dest).getChannel();
  58. outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
  59. } catch (FileNotFoundException e) {
  60. e.printStackTrace();
  61. } catch (IOException e) {
  62. e.printStackTrace();
  63. } finally {
  64. try {
  65. inputChannel.close();
  66. } catch (IOException e) {
  67. e.printStackTrace();
  68. }
  69. try {
  70. outputChannel.close();
  71. } catch (IOException e) {
  72. e.printStackTrace();
  73. }
  74. }
  75. }
  76.  
  77. public static void copyFolder(String oldPath, String newPath) {
  78. try {
  79. // 如果文件夹不存在,则建立新文件夹
  80. (new File(newPath)).mkdirs();
  81. // 读取整个文件夹的内容到file字符串数组,下面设置一个游标i,不停地向下移开始读这个数组
  82. File filelist = new File(oldPath);
  83. String[] file = filelist.list();
  84. // 要注意,这个temp仅仅是一个临时文件指针
  85. // 整个程序并没有创建临时文件
  86. File temp = null;
  87. for (int i = 0; i < file.length; i++) {
  88. // 如果oldPath以路径分隔符/或者\结尾,那么则oldPath/文件名就可以了
  89. // 否则要自己oldPath后面补个路径分隔符再加文件名
  90. // 谁知道你传递过来的参数是f:/a还是f:/a/啊?
  91. if (oldPath.endsWith(File.separator)) {
  92. temp = new File(oldPath + file[i]);
  93. } else {
  94. temp = new File(oldPath + File.separator + file[i]);
  95. }
  96.  
  97. // 如果游标遇到文件
  98. if (temp.isFile()) {
  99. FileInputStream input = new FileInputStream(temp);
  100. // 复制并且改名
  101. FileOutputStream output = new FileOutputStream(newPath
  102. + "/" + (temp.getName()).toString());
  103. byte[] bufferarray = new byte[1024 * 64];
  104. int prereadlength;
  105. while ((prereadlength = input.read(bufferarray)) != -1) {
  106. output.write(bufferarray, 0, prereadlength);
  107. }
  108. output.flush();
  109. output.close();
  110. input.close();
  111. }
  112. // 如果游标遇到文件夹
  113. if (temp.isDirectory()) {
  114. copyFolder(oldPath + "/" + file[i], newPath + "/" + file[i]);
  115. }
  116. }
  117. } catch (Exception e) {
  118. System.out.println("复制整个文件夹内容操作出错");
  119. }
  120. }
  121. }

效果图

备注:有时候会出现渲染加载不出来的问题,可以修改下布局的创建顺序,改为创建一个控件就马上加载

unity打成aar上传到maven库的工具的更多相关文章

  1. aar上传maven库工具

    需求:本地aar文件上传到maven库 参考我之前的博客gradle上传本地文件到远程maven库(nexus服务器) 下面是java图形化工具代码 package com.jinkejoy.buil ...

  2. 用eclipse怎样将本地的项目打成jar包上传到maven仓库

    使用maven的项目中,有时需要把本地的项目打成jar包上传到mevan仓库. 操作如下: 前提:pom文件中配置好远程库的地址,否则会报错 1.将maven 中的settings文件配置好用户名和密 ...

  3. Maven系列(二) -- 将开源库上传到maven仓库私服

    前言 之前简单说了下Maven的搭建,现在跟大家说一下如何将自己的aar传到我们新搭建的maven仓库里面,接下来我们就从最基本的新建一个library开始讲述整个流程,话不多说,让我们把愉快的开始吧 ...

  4. Github开源Java项目(Disconf)上传到Maven Central Repository方法详细介绍

    最近我做了一个开源项目 Disconf:Distributed Configuration Management Platform(分布式配置管理平台) ,简单来说,就是为所有业务平台系统管理配置文件 ...

  5. 多个module实体类集合打一个jar包并上传至远程库

    本章内容主要分享多个module中的实体类集合生成到一个jar包中,并且发布到远程库:这里采用maven-assembly-plugin插件的功能来操作打包,内容不长却贴近实战切值得拥有,主要节点内容 ...

  6. DropzoneJS 可以拖拽上传的js库

    介绍 可以拖拽上传的 js库 网址 http://www.dropzonejs.com/ 同类类库 1.jquery.fileupload   http://blueimp.github.io/jQu ...

  7. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1、JIRA账号注册

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

  8. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2、PGP下载安装与密钥生成发布

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

  9. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):3、Maven独立插件安装与settings.xml配置

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

随机推荐

  1. 信息摘要算法之六:HKDF算法分析与实现

    HKDF是一种特定的键衍生函数(KDF),即初始键控材料的功能,KDF从其中派生出一个或多个密码强大的密钥.在此我们想要描述的是基于HMAC的HKDF. 1.HKDF概述 密钥派生函数(KDF)是密码 ...

  2. Confluence 6 跟踪你安装中的自定义修改

    在 Confluence 中的系统信息(System Information)部分,有一个 修改(Modification)的选项.在这个选项中列出了自你 Confluence 安装以来,你 Conf ...

  3. Confluence 6 从外部小工具中注册访问

    希望从 Confluence 中删除一个小工具,你可以选择小工具边上的 URL ,然后单击删除(Delete). 如果你希望取消订阅一个应用的小工具,你需要删除整个订阅.你不能仅仅删除你订阅中的某一个 ...

  4. 兼容性很好的纯css圆角

    <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...

  5. nodejs之crypto加密算法

    示例 const crypto = require('crypto'); const hash = crypto.createHash('sha256'); hash.update('some dat ...

  6. 分布式Dubbo快速入门

    目录 Dubbo入门 背景 zookeeper安装 发布Dubbo服务 Dubbo Admin管理 消费Dubbo服务 抽取与依赖版本管理 Dubbo入门 Editor:SimpleWu Dubbo是 ...

  7. spring boot 解决跨域访问

    package com.newings.disaster.shelters.configuration; import org.springframework.context.annotation.B ...

  8. Intenet 地址

    java.net.InetAddress类是java对Ip地址(包括ipv4和ipv6)的高层表示,大多数其他网络类都要用到这个类,包括Socket, ServerSocket, URL, Datag ...

  9. java----Java的栈,堆,代码,静态存储区的存储顺序和位置

    转载:https://blog.csdn.net/zhangbaoanhadoop/article/details/82193497

  10. Gson将字符串转map时,int默认为double类型

      gson能够将json字符串转换成map, 但是在转成map时, 会默认将字符串中的int , long型的数字, 转换成double类型 , 数字会多一个小数点 , 如 1 会转成 1.0 Gs ...