/
lang_android_app_dagger.go
130 lines (120 loc) · 3.86 KB
/
lang_android_app_dagger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package main
import "path/filepath"
type androidApplicationWithDagger struct {
androidAppShared
}
func (aa *androidApplicationWithDagger) templateAlias() string {
return "lang/android_app_dagger"
}
func (aa *androidApplicationWithDagger) describe() string {
return "An android application with a default dagger 2 implementation"
}
func (aa *androidApplicationWithDagger) generateLangSpecificFiles(data *ProjectData, subdir string) {
aa.androidAppShared.generateAppResources(data, subdir)
mainRoot := pathWithOptSubdir(subdir, "src", "main")
mainPath := filepath.Join(mainRoot, "java", data.Group.asPath())
testPath := pathWithOptSubdir(subdir, "src", "test", "java", data.Group.asPath())
androidTestPath := pathWithOptSubdir(subdir, "src", "androidTest", "java", data.Group.asPath())
mainAppPath := filepath.Join(mainPath, "app")
mainMainPath := filepath.Join(mainPath, "main")
mainBasePath := filepath.Join(mainPath, "base")
testAppPath := filepath.Join(testPath, "app")
testMainPath := filepath.Join(testPath, "main")
testBasePath := filepath.Join(testPath, "base")
mkdir(androidTestPath, mainAppPath, mainMainPath, mainBasePath, testAppPath, testMainPath, testBasePath)
templateTemplateableToFile(
"proguard-rules.pro",
filepath.Join(subdir, "proguard-rules.pro"),
aa,
data)
templateTemplateableToFile(
"src_files/AndroidManifest.xml",
filepath.Join(mainRoot, "AndroidManifest.xml"),
aa,
data)
templateTemplateableToFile(
"src_files/app/App.java",
filepath.Join(mainAppPath, data.CamelNameWithoutApp()+"App.java"),
aa,
data)
templateTemplateableToFile(
"src_files/app/AppComponent.java",
filepath.Join(mainAppPath, data.CamelNameWithoutApp()+"AppComponent.java"),
aa,
data)
templateTemplateableToFile(
"src_files/app/AppModule.java",
filepath.Join(mainAppPath, data.CamelNameWithoutApp()+"AppModule.java"),
aa,
data)
templateTemplateableToFile(
"src_files/app/RootBindingModule.java",
filepath.Join(mainAppPath, "RootBindingModule.java"),
aa,
data)
templateTemplateableToFile(
"src_files/base/BaseAppCompatActivity.java",
filepath.Join(mainBasePath, "BaseAppCompatActivity.java"),
aa,
data)
templateTemplateableToFile(
"src_files/base/BaseFragment.java",
filepath.Join(mainBasePath, "BaseFragment.java"),
aa,
data)
templateTemplateableToFile(
"src_files/base/BaseActivityModule.java",
filepath.Join(mainBasePath, "BaseActivityModule.java"),
aa,
data)
templateTemplateableToFile(
"src_files/main/MainActivity.java",
filepath.Join(mainMainPath, "MainActivity.java"),
aa,
data)
templateTemplateableToFile(
"src_files/main/MainFragment.java",
filepath.Join(mainMainPath, "MainFragment.java"),
aa,
data)
templateTemplateableToFile(
"src_files/main/MainActivityModule.java",
filepath.Join(mainMainPath, "MainActivityModule.java"),
aa,
data)
templateTemplateableToFile(
"src_files/test/ut/BuildMockspresso.java",
filepath.Join(testPath, "BuildMockspresso.java"),
aa,
data)
templateTemplateableToFile(
"src_files/test/ut/main/MainActivityTest.java",
filepath.Join(testMainPath, "MainActivityTest.java"),
aa,
data)
templateTemplateableToFile(
"src_files/test/ut/main/MainFragmentTest.java",
filepath.Join(testMainPath, "MainFragmentTest.java"),
aa,
data)
templateTemplateableToFile(
"src_files/test/ut/app/MockspressoTestApp.java",
filepath.Join(testAppPath, "MockspressoTestApp.java"),
aa,
data)
templateTemplateableToFile(
"src_files/test/ut/base/BaseAppCompatActivityTest.java",
filepath.Join(testBasePath, "BaseAppCompatActivityTest.java"),
aa,
data)
templateTemplateableToFile(
"src_files/test/ut/base/BaseFragmentTest.java",
filepath.Join(testBasePath, "BaseFragmentTest.java"),
aa,
data)
templateTemplateableToFile(
"src_files/test/it/MainActivityInstrumentedTest.java",
filepath.Join(androidTestPath, "MainActivityInstrumentedTest.java"),
aa,
data)
}