Gradle 2.3-rc-4 is now available for testing

The Gradle team is pleased to announce that the 4th release candidate for Gradle 2.3 is now available.

Download links and release notes can be found as always at http://gradle.org/release-candidate.

This 4th release candidate for 2.3 adds fixes for GRADLE-3240 that affected Ivy exclusion rules and some documentation formatting issues. Please see the release notes for more information on how this may affect your builds.

Please try Gradle 2.3-rc-4 with your projects and let us know your experiences. We expect to release Gradle 2.3 final very soon.

Thanks,

-Sterling

Hi there,

I migrated a mixed C++/Java project yesterday to Gradle 2.3 RC 4 which went astonishingly well. Unfortunately I encountered a small problem with compiling for different available platforms in the native part of the build. My model specifies buildTypes and platforms like so

buildTypes {
    debug
    release
  }
    platforms {
    x64 { architecture "x86_64" }
    x86 { architecture "x86" }
     }

Up to and including Gradle 2.2.1 this automatically compiled x86 and x86_64 variants for Debug and Release targets of my two native libraries on Windows. I am currently using Visual Studio 2013 as tool chain here. After upgrading to Gradle 2.3 RC 4 only the x86 part is build which is unfortunate because my Java runtime is of course 64 bit and so I cannot load the resulting JNI library in the testing phase. Do you have an idea what I am doing wrong here? Any idea would be appreciated.

The native support has undergone some fundamental changes in Gradle 2.3, as mentioned in http://gradle.org/docs/release-candidate/release-notes#major-changes-to-incubating-‘native-component’-and-‘jvm-component’-plugins.

However, one change that should probably be explicitly called out is that Gradle will now build variants for the ‘current’ platform only: Gradle makes a very limited attempt to determine the best platform to build for. If you want to build for a different platform, then you can explicitly target the component to that target platform:

components {
    myLib(NativeLibrarySpec) {
        targetPlatform "x86"
        targetPlatform "x86_64"
    }
}

Note that Gradle makes a set of platforms available to you by default, so you can probably get away without a ‘platforms’ block:

components {
    myLib(NativeLibrarySpec) {
        targetPlatform "windows_x86"
        targetPlatform "windows_x86_64"
    }
}

The set of platforms is not currently documented, see the source for more details. Note that this mechanism is almost certainly going to change further in Gradle 2.4.

Hi Daz,

thanks for pointing me to the source. The following code seems to have been the culprit all along

// TODO:DAZ This is a very limited implementation of defaults, just to get the build passing
if (os.isWindows()) {
     // Always use x86 as default on windows
     return platformName(OS_WINDOWS, ARCH_X86);
}

I am building on Windows, Linux and OS X and only on 64-bit Windows Gradle chooses to build 32-bit binaries. In my case this is not what I want, which brought me to the platforms block previously. Removing it now breaks the build as I reference targetPlatform == platforms.x64 in the repositories block for prebuild binaries (and also in the binaries block).

So, if I understand you correctly with the changes the way forward in Gradle 2.3 is to specify the targetPlatform explicitly, i.e. I would like to pase it on the current operating system architecture. I will see how that goes.

I was aware of the fact that the native build support is undergoing fundamental changes currently, but the project is in mid-development and I like to integrate early with my dependencies (Gradle being one of them, along with Jersey, Casablanca, Boost, OpenSSL and some others) instead of being stuck with an old Gradle version.

May I ask why Gradle only on Windows assumes that 32-bit is the correct platform even if compiling on 64-bit? Neither Linux nor OS X follow that assumption…

Thanks a lot,

Marco

You don’t need to remove the ‘platforms’ block: the simplest change should be to follow the first example I gave above.

Alternatively, you could remove the ‘platforms’ block, and only reference the ‘canned’ platforms in your build script. If you want to target all platforms with x86-64 architecture, you can use ‘platform.architecture.name == ‘x86-64’’ (the canonical architecture name).

The reason for windows targeting x86 by default is exactly as it says in the comment: “just to get the build passing”. Unfortunately this stuff was de-prioritised and I wasn’t able to take it further. That should be addressed in Gradle 2.4 (I hope).

Thanks for your suggestions, I will try to apply them tomorrow and I am looking forward to further changes to the native build support in 2.4. My build is currently rather involved, I guess partially because of my own ignorance and partially because one still has to provide many things to the compiler and linker. Anyhow your help is much appreciated.

OK, to wrap this up: I applied your very first suggestion and added the 'targetPlatform’s explicitly. Works like a charm.