How to deal with URL's in gradle ( manipulate strings, extract parts)

I need to download a file via URL. I pass in the URL on the gradle command line, use the Gradle download plugin and all is well.

Now I need to do something with that file so I need to extract the last part of the URL as the file name.

The ‘String’ and ‘URI’ classes are not available to me in my gradle script, what is the best way to go about this?

I attempted to import in my script but the types were not available.

I tried passing the base URI and the file name but the download plugin does not accept a reconstructed string as the ‘src’ param (not sure why but it simply throws some sort of exception ).

Gradle doesn’t provide its own API to manipulate URLs, but both ‘java.lang.String’ and ‘’ are available in build scripts (like all other standard JRE classes).

I tried that initially but I do not have access to I do have a line

apply plugin: ‘java’

but that does not seem to work.

I did: import

but that is not recognized. If there is something I need to do to get gradle to recognize both Java and Groovy classes, that would help and can go from there.

As I said, these classes are always available, and Groovy even imports ‘*’ automatically. If you need more help, please state your Gradle version, provide a self-contained example, state which exact command you are executing, and which exact error message you are getting. Please wrap all code and output with HTML code tags.

When I try to use the class, it is not recognized as being in my classpath by IntelliJ, I lookin +External libraries and noting is there referring to . Is there additional configuration that I need ?

I see $GROOVY_HOME/lib/groovy-all, how is the JRE made available to Groovy? I have been through the IntelliJ docs, everything seems to be in order there.

You didn’t say that this is (just) about the IDE setup. You always need to configure a JDK in IntelliJ, whether you use Gradle or not. Gradle support in IntelliJ 12 isn’t great, although it became better in 12.1.4 or so. Gradle support in IntelliJ 13 EAP looks much more promising already. Anyway, no matter what IntelliJ shows, these types will be available when you run the build.