I am in the process of moving our legacy ant build into gradle. I want to do this incrementally as not to break the build for everyone on my team as I fumble through the conversion. Thus I just want gradle to build my existing ant scripts and then I can slowly move the gradle way.
The first step for me is just getting my ant script to build in gradle. The problem is that the current ant script only works when the CLASSPATH environment has been setup before running ant.
When using the ant.importBuild(‘build.xml’) the ant build fails to find the jars that were specified on the environment classpath.
How can I get gradle to use my environment CLASSPATH in the imported ant tasks?
I guess you could set the environment variable CLASSPATH as part of your Gradle start script which should propagate to the Ant invocation as well. Does CLASSPATH point to a directory that is part of your checked out project source code? If that’s the case you mind want to completely get rid of this by referring to the directory/files with a relative path.
The classpath points to some application server jars, and is itself set via a script. These jars reside with the application server files, not the source.
Could you elaborate on what you mean by “setting the environment variable CLASSPATH as part of your gradle start script”. What does this look like? just a -D option on the gradle command line or some other gradle thing I don’t know about?
The classpath points to some application server jars, and is itself set via a script. These jars reside with the application server files, not the source.
The end goal should be to use dependency management for this. Having to set an environment for every build script user is brittle.
Could you elaborate on what you mean by “setting the environment variable CLASSPATH as part of your gradle start script”. What does this look like? just a -D option on the gradle command line or some other gradle thing I don’t know about?
I am talking about setting an OS-specific environment variable in either a shell language or Windows batch file in gradlew, gradlew.bat for the Wrapper or gradle, gradle.bat in your local Gradle installation.