@@ -19,7 +19,7 @@ class AmplifyTools implements Plugin<Project> {
19
19
project. task(' createAmplifyApp' ) {
20
20
def npx = ' npx'
21
21
22
- if (project. file(gradleConfigFileName). exists()) {
22
+ if (project. file(" ${ project.projectDir } / $ gradleConfigFileName " ). exists()) {
23
23
return
24
24
}
25
25
@@ -29,6 +29,7 @@ class AmplifyTools implements Plugin<Project> {
29
29
30
30
try {
31
31
project. exec {
32
+ workingDir ${project. projectDir}
32
33
commandLine npx, ' amplify-app' , ' --platform' , ' android'
33
34
}
34
35
} catch (commandLineFailure) {
@@ -37,7 +38,7 @@ class AmplifyTools implements Plugin<Project> {
37
38
}
38
39
39
40
project. task(' getConfig' ) {
40
- def inputConfigFile = project. file(' amplify-gradle-config.json' )
41
+ def inputConfigFile = project. file(" ${ project.projectDir } / amplify-gradle-config.json" )
41
42
if (inputConfigFile. isFile()) {
42
43
def configText = inputConfigFile. text
43
44
def jsonSlurper = new JsonSlurper ()
@@ -53,9 +54,9 @@ class AmplifyTools implements Plugin<Project> {
53
54
project. getConfig. dependsOn(' createAmplifyApp' )
54
55
55
56
project. task(' datastoreSync' ) {
56
- def transformConfFile = project. file(' amplify/backend/api/amplifyDatasource/transform.conf.json' )
57
- if (project. file(' amplify/backend/api' ). exists()) {
58
- new File (' amplify/backend/api' ). eachFileRecurse(groovy.io.FileType . FILES ) {
57
+ def transformConfFile = project. file(" ${ project.projectDir } / amplify/backend/api/amplifyDatasource/transform.conf.json" )
58
+ if (project. file(" ${ project.projectDir } / amplify/backend/api" ). exists()) {
59
+ new File (" ${ project.projectDir } / amplify/backend/api" ). eachFileRecurse(groovy.io.FileType . FILES ) {
59
60
if (it. name. endsWith(' transform.conf.json' )) {
60
61
transformConfFile = project. file(it)
61
62
}
@@ -95,6 +96,7 @@ class AmplifyTools implements Plugin<Project> {
95
96
96
97
doLast {
97
98
project. exec {
99
+ workingDir ${project. projectDir}
98
100
commandLine amplify, ' codegen' , ' model'
99
101
}
100
102
}
@@ -144,12 +146,14 @@ class AmplifyTools implements Plugin<Project> {
144
146
providersConfig = StringEscapeUtils . escapeJavaScript(providersConfig)
145
147
}
146
148
147
- if (project. file(' ./amplify/.config/local-env-info.json' ). exists()) {
149
+ if (project. file(" ${ project.projectDir} /amplify/.config/local-env-info.json" ). exists()) {
150
+ workingDir ${project. projectDir}
148
151
project. exec {
149
152
commandLine amplify, ' push' , ' --yes'
150
153
}
151
154
} else {
152
155
project. exec {
156
+ workingDir ${project. projectDir}
153
157
commandLine amplify, ' init' ,
154
158
' --amplify' , amplifyConfig,
155
159
' --providers' , providersConfig,
@@ -162,9 +166,9 @@ class AmplifyTools implements Plugin<Project> {
162
166
project. amplifyPush. dependsOn(' datastoreSync' )
163
167
164
168
project. task(' addModelgenToWorkspace' ) {
165
- if (project. file(' . /.idea/workspace.xml' ). exists()) {
169
+ if (project. file(" ${ project.projectDir } /.idea/workspace.xml" ). exists()) {
166
170
// Open XML file
167
- def xml = new XmlParser (). parse(' . /.idea/workspace.xml' )
171
+ def xml = new XmlParser (). parse(" ${ project.projectDir } /.idea/workspace.xml" )
168
172
def RunManagerNode = xml. component. find { it. ' @name' == ' RunManager' } as Node
169
173
def configModelgenCheck = null
170
174
if (RunManagerNode ) {
@@ -193,7 +197,7 @@ class AmplifyTools implements Plugin<Project> {
193
197
RunManagerNode . append(configurationNode)
194
198
195
199
// Save File
196
- def writer = new FileWriter (' . /.idea/workspace.xml' )
200
+ def writer = new FileWriter (" ${ project.projectDir } /.idea/workspace.xml" )
197
201
198
202
// Pretty print XML
199
203
groovy.xml.XmlUtil . serialize(xml, writer)
@@ -202,9 +206,9 @@ class AmplifyTools implements Plugin<Project> {
202
206
}
203
207
204
208
project. task(' addAmplifyPushToWorkspace' ) {
205
- if (project. file(' . /.idea/workspace.xml' ). exists()) {
209
+ if (project. file(" ${ project.projectDir } /.idea/workspace.xml" ). exists()) {
206
210
// Open file
207
- def xml = new XmlParser (). parse(' . /.idea/workspace.xml' )
211
+ def xml = new XmlParser (). parse(" ${ project.projectDir } /.idea/workspace.xml" )
208
212
def RunManagerNode = xml. component. find { it. ' @name' == ' RunManager' } as Node
209
213
def configAmplifyPushCheck = null
210
214
if (RunManagerNode ) {
@@ -233,7 +237,7 @@ class AmplifyTools implements Plugin<Project> {
233
237
RunManagerNode . append(configurationNode)
234
238
235
239
// Save File
236
- def writer = new FileWriter (' . /.idea/workspace.xml' )
240
+ def writer = new FileWriter (" ${ project.projectDir } /.idea/workspace.xml" )
237
241
238
242
// Pretty print XML
239
243
groovy.xml.XmlUtil . serialize(xml, writer)
0 commit comments