I am currently modulating our gradle assembly to have a libs / commons.gradle file containing a lot of global stuff. I need this because various branches of software are being developed in parallel, and we would like to avoid distributing every change to the script file among all branches.
So, I created this lib file and used "apply from" to download it:
apply: 'gradle / glib / commons.gradle'
Inside commons.gradle, I define the svnrevision function:
...
def svnRevision = { ISVNOptions options = SVNWCUtil.createDefaultOptions(true); SVNClientManager clientManager = SVNClientManager.newInstance(options); SVNStatusClient statusClient = clientManager.getStatusClient(); SVNStatus status = statusClient.doStatus(projectDir, false); SVNRevision revision = status.getCommittedRevision(); return revision.getNumber().toString(); }
...
I call a function from mine, including build.gradle:
...
task writeVersionProperties { File f = new File(project.webAppDirName+'/WEB-INF/version.properties'); if (f.exists()) { f.delete(); } f = new File(project.webAppDirName+'/WEB-INF/version.properties'); FileOutputStream os = new FileOutputStream(f); os.write(("version="+svnRevision()).getBytes()); os.flush(); os.close(); }
...
But I finish:
...
FAILURE: Build failed with an exception. * Where: Build $PATH_TO/build20.gradle * What went wrong: A problem occurred evaluating root project 'DEV_7.X.X_GRADLEZATION'. > Could not find method svnRevision() for arguments [] on root project 'DEV_7.X.X_GRADLEZATION'.
...
So my query is : how can I name the subfunction in gradle that is defined in the included script?
Any help appreciated!
source share