-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for gradle file editing #1125
Comments
The classpath issue is the biggest hurdle. You can get some basic editor support by adding "gradleApi()" in your dependencies block. Here are some issues related to that: eclipse-buildship/buildship#547 You can add a dsld script to your project like this (the is poc/alpha stuff): package dsld
def isBuildScript = fileExtension('gradle') & (~fileName('settings.gradle'))
contribute(isBuildScript & isThisType()) {
delegatesTo 'org.gradle.api.Project'
method name: 'apply', type: void, params: [block: Closure]
method name: 'apply', type: void, namedParams: [plugin: String, from: Object, to: Object]
method name: 'apply', type: void, params: [action: 'org.gradle.api.Action<? super org.gradle.api.plugins.ObjectConfigurationAction>']
}
contribute(isBuildScript & enclosingCallName('configurations') & inClosure() & currentType('org.gradle.api.Project')) {
setDelegateType('org.gradle.api.artifacts.ConfigurationContainer')
}
contribute(isBuildScript & enclosingCallName('dependencies') & inClosure() & currentType('org.gradle.api.Project')) {
setDelegateType('org.gradle.api.artifacts.dsl.DependencyHandler')
}
contribute(isBuildScript & enclosingCallName('repositories') & inClosure() & currentType('org.gradle.api.Project')) {
setDelegateType('org.gradle.api.artifacts.dsl.RepositoryHandler')
}
contribute(fileName('settings.gradle') & isThisType()) {
setDelegateType('org.gradle.api.initialization.Settings')
}
/* https://github.com/gluck/gradle-scripts/blob/master/GradleDSLD.dsld.custom
artifacts 'org.gradle.api.artifacts.dsl.ArtifactHandler'
install, upload 'org.gradle.api.tasks.Upload'
task 'org.gradle.api.Task'
clean 'org.gradle.api.tasks.Delete'
block('org.gradle.api.tasks.Upload', 'repositories') {
setDelegateType 'org.gradle.api.artifacts.dsl.RepositoryHandler'
delegatesTo 'org.gradle.api.plugins.MavenRepositoryHandlerConvention'
collectOuterScope(scope).each {
delegatesTo it
}
}
blockSetDelegateType 'org.gradle.api.plugins.MavenRepositoryHandlerConvention', 'mavenInstaller', 'org.gradle.api.artifacts.maven.MavenResolver'
blockSetDelegateType 'org.gradle.api.plugins.MavenRepositoryHandlerConvention', 'mavenDeployer', 'org.gradle.api.artifacts.maven.GroovyMavenDeployer'
rootBlockSetDelegateType 'eclipse' , 'org.gradle.plugins.ide.eclipse.model.EclipseModel'
blockSetDelegateType 'org.gradle.plugins.ide.eclipse.model.EclipseModel', 'classpath', 'org.gradle.plugins.ide.eclipse.model.EclipseClasspath'
blockSetDelegateType 'org.gradle.plugins.ide.eclipse.model.EclipseClasspath', 'file', 'org.gradle.plugins.ide.api.XmlFileContentMerger'
rootBlockSetDelegateType 'idea' , 'org.gradle.plugins.ide.idea.model.IdeaModel'
// requires gradle-plugins-1.2.jar & sources
rootBlockSetDelegateType 'javadoc' ,'org.gradle.api.tasks.javadoc.Javadoc'
rootBlockSetDelegateType 'groovydoc' ,'org.gradle.api.tasks.javadoc.Groovydoc'
// requires gradle-scala-1.2.jar & sources
rootBlockSetDelegateType 'scaladoc' ,'org.gradle.api.tasks.scala.ScalaDoc'
// requires gradle-signing-1.2.jar & sources
rootBlockSetDelegateType 'signing' ,'org.gradle.plugins.signing.SigningExtension'
*/ |
I was thinking if we can provide virtual project when opening a gradle file in groovy editor and include this dsl and the gradle api dependencies ? Do you think that's possible ? |
You can try out the DSLD now by adding it to your |
@eric-milles i tried you suggestion. But it seems like the dsl file isn’t getting loaded. For example blocks like dependencies and properties of dependencies block is not completing. And when i check the dsld settings window I cannot see the global dsld i added either |
If you add a DSLD to the global folder, you need to restart Eclipse or run Window > Preferences > Groovy > DSLD > Recompile Scripts. |
Once a DSLD is accepted, you can look at Console view > New toolbar button > Groovy Event Console to see the compiler's logging. If you add |
@eric-milles i added the file content at ~/.groovy/greclipse/global_dsld_support/gradle.dsld But this how the eclipse settings look like And following is my gradle file
I still don't get gradle specific completions. |
I even tried converting the project into a groovy project as well. But it didn't work. |
|
Nice it is working now. |
For now, I'd stick with enhancing the DSLD so that you get the experience you are looking for. If you can't get there, all the bootstrapping is unneeded. Can you show a quick screenshot of what you have and describe what kind of completion proposals you are expecting? |
In the below i'm expecting to get completions for api and implementation below i'm expecting for completions of mavenCentral, maven blocks like https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:declaring_multiple_repositories |
For If there are items you want for completion beyond what the delegate type offers, then more DSLD script will be required. For example, adding "method name:'jcenter', type:void, parameters:[]" inside the "contribute(isBuildScript & enclosingCallName('dependencies') ..." closure would enable the jcenter method. The DSLD given in the second comment is a skeleton. There will be much more script required to provide for a typical gradle build script. |
Today in eclipse buildship team is not providing gradle file editing support pointing this project doesn't support well. I would like to request to have support for gradle file from this project if build ship is not intrested.
From what i understand we need to have a classpath for a give gradle file based on
I think if we can have support to add a custom classpath for a groovy file editor and open it we can achieve some support for gradle file editing.
The text was updated successfully, but these errors were encountered: