xtext / xtext-gradle-plugin

Gradle plugins for using Xtext and Xtend
Eclipse Public License 1.0
48 stars 18 forks source link

DefaultXtextSourceDirectorySet has no outputDir property #125

Closed Sandared closed 6 years ago

Sandared commented 6 years ago

I have an OSGi project that is built with the bnd-gradle plugin where I want to use Xtend as my programming language. When I add the xtend gradle plugin to the project I get a build error complaining about:

No such property: outputDir for class: org.xtext.gradle.tasks.internal.DefaultXtextSourceDirectorySet

The gradle bnd-workspace plugin tries to set the outputDir property on the SourceDirectorySet "test.java" which can be seen here which seems to lead to the above mentioned error.

I'm not sure if this is an issue for Xtext or bnd, but in the official gradle documentation a SourceDirectorySet has the method setOutputDir(File outputDir), so maybe this one should exist also for the DefaultXtextSourceDirectorySet?

cdietrich commented 6 years ago

I have no idea on that. We don’t implement the gradle sourcedirectoryset interface and if we would I have no idea how. Maybe @oehme has some idea or comments on that

oehme commented 6 years ago

Can you please create a reproducible sample project?

Sandared commented 6 years ago

I created a sample repository here

The gradle release task should create a jar in the cnf/release folder. This is where the error occurs.

oehme commented 6 years ago

The linked line number is off, because the bnd plugin has evolved since the version you are using. The issue is actually in this line, which assumes that every language has an outputDir property. This is true for java, scala and groovy, but not Xtext. Xtext can have multiple output directories.

The bnd plugin should put a guard in there to check whether such a property actually exists, because it is just a convention, not a hard rule.

oehme commented 6 years ago

One thing we could do is assume that setOutputDir means "set the default outlet". A PR for that would be welcome.

oehme commented 6 years ago

I thought about the above again and it actually wouldn't make sense, because BND assumes that outputDir means "classes go here", which is not true for Xtext (which generates sources). So really this needs to be fixed in the BND plugin. It should explicitly list the languages it wants to support like Scala and Groovy.

Sandared commented 6 years ago

Thanks for your work. I will open an issue at bnd.

Sandared commented 6 years ago

Regarding the answer of BJ Hargrave on the issue I opened for the bnd-gradle-plugin: Wouldn't it be sensible to add an additional property outputDir to the DefaultXtextSourceDirectorySet. It seems to me that it tries to appear as a SourceDirectorySet which, according to the gradle docs should have such a property. If Xtend isn't using this property anyway (No class files are created but source files) then there would be no harm in offering this property for any other plugin that wants to interact with the DefaultXtextSourceDirectorySet as with any other SourceDirectorySet (set the path where to look for class files). I don't have that much experience with gradle, so please correct me if I'm wrong.

WDYT?

oehme commented 6 years ago

There is no guarantee that every extension on a SourceSet is of type SourceDirectorySet. This just so happens to be true for Java, Groovy and Scala. Other plugins could add any other kind of extension. The bnd plugin shouldn't make assumptions about their type.