carlomorelli / licensescan-maven-plugin

Maven plugin for analysing the licenses in dependencies and transitive dependencies, asserting compatibility and potentially fail the build if forbidden licenses appear
MIT License
36 stars 8 forks source link

Non-default packaging identifier 'bundle' fails to resolve #6

Open sboschman opened 6 years ago

sboschman commented 6 years ago

Postgresql jdbc drivers use the maven-bundle-plugin (http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html), which means the packaging is 'bundle'.

https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/pom.xml http://central.maven.org/maven2/org/postgresql/postgresql/42.2.2/postgresql-42.2.2.pom

Seems the Maven ProjectBuilder can't handle this: [ERROR] Failed to execute goal com.github.carlomorelli:licensescan-maven-plugin:1.1:audit (default) on project my-project: Error while building project: Some problems were encountered while processing the POMs: [ERROR] [ERROR] Unknown packaging: bundle @ line 11, column 14: 1 problem was encountered while building the effective model for org.postgresql:postgresql:42.2.2 [ERROR] [ERROR] Unknown packaging: bundle @ line 11, column 14

chiston commented 5 years ago

Hi. Did you manage to find a solution?

adwk67 commented 5 years ago

The licenses are downloaded/parsed in a similar way in the license-maven-plugin:

See https://github.com/mojohaus/license-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/license/download/LicensedArtifactResolver.java

The difference being that in license-maven-plugin both setResolveDependencies and setProcessPlugins are set to false:

ProjectBuildingRequest projectBuildingRequest
                = new DefaultProjectBuildingRequest( mavenSession.getProjectBuildingRequest() )
                        .setRemoteRepositories( remoteRepositories )
                        .setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL )
                        .setResolveDependencies( false )
                        .setProcessPlugins( false );

If I add these two lines to MainMojo/analyze it works for me with e.g. postgresql dependencies:

buildingRequest.setResolveDependencies(false);
buildingRequest.setProcessPlugins(false);

I would have thought that dependency resolution was important, although I couldn't find a place in the license-maven-plugin code where that can be configured.

UPDATE Actually, it seems as though setProcessPluginsis the culprit, as I can set setResolveDependenciesto trueand it still works.

carlomorelli commented 5 years ago

Interesting. Care to work on a pull request about this? Unfortunately I can't work on it at the moment. I will produce a release after merging.

adwk67 commented 5 years ago

I've just opened pull-request #17.

rsimonton commented 3 years ago

Was excited to use this plugin as it seems to offer just what I need but ran into this same issue. Looks like this project's been abandoned.

carlomorelli commented 3 years ago

Project is not abandoned at all, had a release 6 months ago. There has been pull request #17 by @adwk67 regarding this issue, but it didn't go forward... yet.

carlomorelli commented 1 year ago

I'm not able to reproduce this bug. Adding the postgresql driver version 42.2.22 to the <dependencies/> block works for me and I don't observe crashes.

If any one is still encountering this problem, could they please help me reproducing it.

linarkou commented 1 month ago

@carlomorelli Hi! I have the same issue with org.xerial.snappy:snappy-java:1.1.10.5 dependency. This is transitive dependency of kafka-clients:3.7.0

[ERROR] Failed to execute goal com.github.carlomorelli:licensescan-maven-plugin:3.2:audit (default-cli) on project feature-store-services: Execution default-cli of goal com.github.carlomorelli:licensescan-maven-plugin:3.2:audit failed: Error while building project . Giving up...: Some problems were encountered while processing the POMs:
[ERROR] [ERROR] Unknown packaging: bundle @ line 6, column 16: 1 problem was encountered while building the effective model for org.xerial.snappy:snappy-java:1.1.10.5
[ERROR] [ERROR] Unknown packaging: bundle @ line 6, column 16