1

I'm trying to update my Gradle version from 2.3 to 2.12. When I run the "eclipse" task to generate the eclipse files I'm running into an issue when using the new version (2.12).

The classpathentry nodes generated in the .classpath file no longer contain the exported="true" attribute which is necessary to create a working run target in eclipse.

With version 2.3

<classpathentry 
sourcepath="/../some-lib-sources.jar" kind="lib" path="/../some-lib.jar"
exported="true"/>

With version 2.12 (exported="true" is missing)

<classpathentry 
sourcepath="/../some-lib-sources.jar" kind="lib" path="/../some-lib.jar"/>

I couldn't find anything helpful about this issue in the Gradle documentation. I'm hoping this is just a simple configuration change.

Does anyone know how to fix this issues?

Update:

So I found the change that I think is causing this issue in the 2.5 release notes

Changes in IDE classpath generation ... All dependencies in projects are marked as exported = false.

.. But I still haven't be able to find any information on how to control what classpathentries get the exported=true attribute.

delux247
  • 2,177
  • 3
  • 21
  • 29

2 Answers2

0

Allowing a build and dependency management tool to manage IDE-specific files is, in my opinion, a fundamental mistake. See my explanation in this answer.

Instead, install Buildship and use it to import your Gradle-based project into Eclipse. Let Eclipse plug-ins do Eclipse stuff and build tools do builds.

Community
  • 1
  • 1
E-Riz
  • 31,431
  • 9
  • 97
  • 134
  • Thanks.. I will definitely take a look at this, but for now we just needed to get this working again. – delux247 Mar 15 '16 at 19:14
  • 1
    It seems that Buildship modifies your Eclipse .classpath files. Certainly when we do Gradle -> Refresh it regens these files. I am never sure what exactly is part of Buildship when looking at the Gradle docs! – davidfrancis Jan 09 '17 at 10:51
0

I ended up fixing this issue by adding the following whenMerged code.

eclipse {
  classpath {
    defaultOutputDir = file('classes')

      file {                
        whenMerged { classpath ->
          classpath.entries.findAll { entry -> entry.kind == 'lib' }*.exported = true                    
      }

    }
  }
}
delux247
  • 2,177
  • 3
  • 21
  • 29