lburgazzoli / gradle-karaf-features-plugin

Apache License 2.0
4 stars 13 forks source link

Plugin adds feature project as project dependency for features without project dependencies #24

Open vhusainov opened 8 years ago

vhusainov commented 8 years ago

Because of the following code on line 74 in com.github.lburgazzoli.gradle.plugin.karaf.features.impl.BundleDefinitionCalculatorMvnImpl:

        (feature.projectDescriptors ?: [ feature.project ]).each { projectDescriptor ->

Plugin adds feature project as project dependency for feature if there is no project dependencies. But feature project actually is not a bundle. I think it is correct to be like this:

        feature.projectDescriptors.each { projectDescriptor ->
lburgazzoli commented 8 years ago

This area need to be improved but you should not be required to specify projects, it has been added for specific needs.

Could you please provide some examples of what you'd expect ?

vhusainov commented 8 years ago

I've got features without project dependencies, just some bundles. And for these features, plugin adds feature project as bundle. It also tries to scan jar for manifest (but it fails if there is no jar if I remove jar artifact for feature project). Example of feature project build.gradle:

configurations {
  aFeature
}
dependencies {
  aFeature 'group1:artifact1:version1'
  aFeature 'group2:artifact2:version2'
}
karafFeatures {
  a {
    bundlesFrom(this.configurations.aFeature)
  }
}

Example of generated feature:

<feature name = 'a'>
  <bundle>mvn:group1/artifact1/version1</bundle>
  <bundle>mvn:group2/artifact2/version2</bundle>
  <bundle>mvn:mygroup/featureprojectname/version</bundle> <!-- should not be here -->
</feature>

With suggested fix, everything works fine, but without it, build fails.

lburgazzoli commented 8 years ago

Unfortunately that fix would cause few problems, I will address this in the coming weeks

SOVALINUX commented 8 years ago

Hi, Today I came into the same problem and I made simple improvement - if in your project no jar file in output then it won't be added as a bundle to result feature However looks like in your case there is a jar/war, but it's not needed

And as I already understood we want to preserve zero configuration for auto adding current project, so we can fix it by adding property like 'addCurrentProject=true|false' with true by default

lburgazzoli commented 8 years ago

I think this can be done in ProjectDescriptor as it is used also to customize the project where the plugin is applied.

But be aware that I'm working to refactor and improve karaf features generation in gradle-karaf-plugin which is supposed to support additional functionalities and match maven's one. In the new implementation the behavior will be the opposite as it will match maven's one which does not include the current project unless specified.