@@ -11,45 +11,60 @@ android2024Project::android2024Project(const std::string & target) : baseProject
11
11
12
12
bool android2024Project::createProjectFile (){
13
13
// Make sure project name doesn't include "-"
14
- std::string packageName { projectName };
15
- ofStringReplace (packageName, " -" , " " );
14
+ // std::string packageName { projectName };
15
+ // ofStringReplace(packageName, "-", "");
16
16
17
- if (!fs::exists (projectDir)) {
18
- fs::create_directory (projectDir);
17
+
18
+ for (auto & f : vector<fs::path> {
19
+ " build.gradle" ,
20
+ " gradle" ,
21
+ " gradle.properties" ,
22
+ " local.properties" ,
23
+ " ofApp/gradle.properties" ,
24
+ " ofApp/proguard-rules.pro" ,
25
+ " proguard.cfg" ,
26
+ " settings.gradle" ,
27
+ }) {
28
+ copyTemplateFiles.push_back ({
29
+ templatePath / f,
30
+ projectDir / f
31
+ });
19
32
}
20
33
21
- // std::vector <std::string> fileNames {
22
- // "build.gradle",
23
- // "settings.gradle",
24
- // "AndroidManifest.xml",
25
- // ".gitignore",
26
- // "gradlew",
27
- // "gradlew.bat",
28
- // };
34
+ copyTemplateFiles.push_back ({
35
+ templatePath / " ofApp" / " build.gradle" ,
36
+ projectDir / " ofApp" / " build.gradle" ,
37
+ { { " emptyExample" , projectName } }
38
+ });
29
39
40
+ // copy and replace where needed
41
+ for (auto & c : copyTemplateFiles) {
42
+ c.run ();
43
+ }
44
+
45
+ // TODO: try
46
+ fs::create_directory (projectDir / " ofApp" );
47
+ // copy recursively and try not overwrite code.
30
48
try {
31
- fs::copy (templatePath, projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
32
- } catch (std::exception & e) {
33
- std::cout << e.what ();
34
- std::cout << " unable to copy android2024 template recursively" << std::endl;
49
+ fs::copy (
50
+ templatePath / " ofApp" / " src" ,
51
+ projectDir / " ofApp" / " src" ,
52
+ fs::copy_options::recursive | fs::copy_options::skip_existing
53
+ );
54
+ } catch (fs::filesystem_error & e) {
55
+ ofLogError () << " copy failed " << e.what () << endl;
35
56
}
36
57
37
- // for (auto & f : fileNames) {
38
- // fs::path to { projectDir / f };
39
- // if (!fs::exists(to)) {
40
- // fs::path from { templatePath / f };
41
- // try {
42
- // fs::copy(from, to);
43
- // } catch(fs::filesystem_error & e) {
44
- // if (f == "AndroidManifest.xml") {
45
- // findandreplaceInTexfile(to, "TEMPLATE_PACKAGE_NAME", packageName);
46
- // } else {
47
- // ofLogError(LOG_NAME) << "error copying template from " << from << " to " << to << e.what();
48
- // }
49
- // }
50
- // }
58
+
59
+ // Leftovers from other
60
+
61
+ // try {
62
+ // fs::copy(templatePath, projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
63
+ // } catch (std::exception& e) {
64
+ // std::cout << e.what();
65
+ // std::cout << "unable to copy android2024 template recursively" << std::endl;
51
66
// }
52
- //
67
+
53
68
// for (auto & p : { string("res") , string("srcJava"), string("gradle") }) {
54
69
// fs::copy (templatePath / p, projectDir / p, fs::copy_options::recursive);
55
70
// }
0 commit comments