@@ -12,14 +12,17 @@ dependencies {
1212
1313task generateMessages (type : JavaExec ) {
1414 classpath = sourceSets. main. runtimeClasspath
15- main = ' pt.lsts.imc.generator.ClassGenerator'
15+ mainClass = ' pt.lsts.imc.generator.ClassGenerator'
1616 workingDir = " $parent . rootDir "
17+
18+ def projectExt = project. ext
19+
1720 // arguments to pass to the application
18- args = [" ${ -> project.ext .imcXmlPath} " ]
19-
21+ args = [" ${ -> projectExt .imcXmlPath} " ]
22+
2023 doFirst {
21- if (project . ext . has(" imcXmlSha" ))
22- args = [" ${ -> project.ext. imcXmlPath} " , " ${ -> project.ext. imcXmlSha} " , " ${ -> project.ext. imcXmlBranch} " , " ${ -> project.ext .imcXmlCommitNote} " ]
24+ if (projectExt . has(" imcXmlSha" ))
25+ args = [" ${ -> projectExt. imcXmlPath} " , " ${ -> projectExt. imcXmlSha} " , " ${ -> projectExt. imcXmlBranch} " , " ${ -> projectExt .imcXmlCommitNote} " ]
2326 }
2427
2528 doLast {
@@ -34,6 +37,8 @@ task downloadImc(type: Download) {
3437 src " https://github.com/${ gradle.ext.imcGitHubRepo} /raw/${ gradle.ext.imcGitHubBranch} /IMC.xml"
3538 dest " ${ parent.rootDir} /src-generated/resources/xml/IMC.xml"
3639
40+ def projectExt = project. ext
41+
3742 doLast {
3843 println (" IMC.xml downloaded to '$dest '." )
3944 def sourceGitHub = " https://api.github.com/repos/${ gradle.ext.imcGitHubRepo} /commits/${ gradle.ext.imcGitHubBranch} " ;
@@ -44,14 +49,14 @@ task downloadImc(type: Download) {
4449 " \n " + " $gradle . ext . imcGitHubBranch " +
4550 " \n " + " url: $sourceGitHub " ;
4651 println (" IMC SHA: ${ commitInfo.sha} " )
47- project . ext . imcXmlSha = " $commitInfo . sha "
52+ projectExt . imcXmlSha = " $commitInfo . sha "
4853 def branchName = getBranchFromCommit()
49- project . ext . imcXmlBranch = branchName == null ? " $gradle . ext . imcGitHubBranch " : branchName
50- project . ext . imcXmlCommitNote = " ${ commitInfo.commit.author.name} (${ commitInfo.commit.author.email} ), " +
54+ projectExt . imcXmlBranch = branchName == null ? " $gradle . ext . imcGitHubBranch " : branchName
55+ projectExt . imcXmlCommitNote = " ${ commitInfo.commit.author.name} (${ commitInfo.commit.author.email} ), " +
5156 " ${ commitInfo.commit.author.date} , " +
5257 " ${ commitInfo.html_url} , " +
5358 " ${ commitInfo.commit.message} "
54- project . ext . imcXmlPath = " ${ parent.rootDir} /src-generated/resources/xml"
59+ projectExt . imcXmlPath = " ${ parent.rootDir} /src-generated/resources/xml"
5560 }
5661}
5762
@@ -99,24 +104,25 @@ task prepImcFolderEnv {
99104}
100105
101106task checkIMCFolderGit {
107+ def projectExt = project. ext
102108 doFirst {
103- if (! file(" ${ project.ext .imcXmlPath} /IMC.xml" ). exists())
104- throw new FileNotFoundException (" No IMC.xml on '${ project.ext .imcXmlPath} '" )
109+ if (! file(" ${ projectExt .imcXmlPath} /IMC.xml" ). exists())
110+ throw new FileNotFoundException (" No IMC.xml on '${ projectExt .imcXmlPath} '" )
105111
106112 copy {
107- from " ${ project.ext .imcXmlPath} /IMC.xml"
113+ from " ${ projectExt .imcXmlPath} /IMC.xml"
108114 into " ${ parent.rootDir} /src-generated/resources/xml"
109115 }
110116
111- def folder = new File (" ${ project.ext .imcXmlPath} /.git" )
117+ def folder = new File (" ${ projectExt .imcXmlPath} /.git" )
112118 if (! folder. exists()) {
113- project . ext . imcXmlSha = " unknown sha"
114- project . ext . imcXmlBranch = " unknown branch"
115- project . ext . imcXmlCommitNote = " unknown commit notes"
119+ projectExt . imcXmlSha = " unknown sha"
120+ projectExt . imcXmlBranch = " unknown branch"
121+ projectExt . imcXmlCommitNote = " unknown commit notes"
116122
117123 File shaFile = new File (" ${ parent.rootDir} /src-generated/resources/xml/IMC.sha" )
118- shaFile. text = " $p roject . ext . imcXmlSha " +
119- " \n " + " $p roject . ext . imcXmlBranch " +
124+ shaFile. text = " $p rojectExt . imcXmlSha " +
125+ " \n " + " $p rojectExt . imcXmlBranch " +
120126 " \n " + " From local folder not on Git" ;
121127
122128 getGitPropsFromFolder. enabled = false
@@ -173,10 +179,25 @@ task updateImc {
173179 group = ' Generator'
174180 dependsOn = [deleteImcAddr]
175181 dependsOn + = downloadImc
176- if (gradle. ext. imcDownloadIMCAddresses == ' true' )
182+
183+ def updateImcRequested = gradle. startParameter. taskNames. any { it?. toLowerCase() == ' updateimc' || it?. toLowerCase()?. endsWith(' :updateimc' ) }
184+ if (updateImcRequested) {
185+ project(' :core' ). processResources. configure {
186+ dependsOn + = downloadImc
187+ }
188+ }
189+
190+ if (gradle. ext. imcDownloadIMCAddresses == ' true' ) {
177191 dependsOn + = downloadImcAddr
178- else
192+ if (updateImcRequested) {
193+ project(' :core' ). processResources. configure {
194+ dependsOn + = downloadImcAddr
195+ }
196+ }
197+ }
198+ else {
179199 dependsOn + = deleteImcAddr
200+ }
180201 dependsOn + = generateMessages
181202}
182203
0 commit comments