Last active
December 19, 2019 04:39
-
-
Save yushijinhun/c4eeaa026132bb7a0dbea040ec0b7ed2 to your computer and use it in GitHub Desktop.
[gradle|jpms|eclipse|buildship] Add modularity support to Buildship
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// - Adds modularity support to Buildship | |
// Code is originally from https://github.com/java9-modularity/gradle-modules-plugin/issues/33#issue-376998502 | |
apply plugin: 'eclipse' | |
eclipse { | |
classpath { | |
file { | |
whenMerged { | |
entries.findAll { isModule(it) }.each { | |
it.entryAttributes['module'] = 'true' | |
} | |
entries.findAll { isSource(it) && isTestScope(it) }.each { | |
it.entryAttributes['test'] = 'true' | |
} | |
entries.findAll { isLibrary(it) && isTestScope(it) }.each { | |
it.entryAttributes['test'] = 'true' | |
} | |
} | |
} | |
} | |
} | |
def isLibrary(entry) { entry.properties.kind == 'lib' } | |
def isTestScope(entry) { entry.entryAttributes['gradle_used_by_scope'] == 'test' } | |
def isModule(entry) { isLibrary(entry) && !isTestScope(entry) } | |
def isSource(entry) { entry.properties.kind == 'src' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment