Git Product home page Git Product logo

Comments (7)

stempler avatar stempler commented on August 24, 2024

Gradle does not support optional dependencies in its dependency management, so that information is lost.

Workaround is easy if you know the bundle where you want to make the dependency optional and the respective package names. You can configure the bundle to use optional package imports, similar to the first example here.

from bnd-platform.

ocroquette avatar ocroquette commented on August 24, 2024

Thanks for the quick reply. I tried that, but it's not working, so I must do something wrong. Here is my script:

buildscript {
  repositories {
      jcenter()
  }
  dependencies {
      classpath 'org.standardout:bnd-platform:1.4.0'
  }
}

repositories {
  mavenCentral()
}

apply plugin: 'org.standardout.bnd-platform'

dependencies {
  platform 'commons-logging:commons-logging:1.1.1'
}

platform {
  bnd(group: 'commons-logging', name: 'commons-logging') {
      optionalImport 'org.apache.avalon.framework.logger'
  }
}

And here is the generated manifest:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Build-Jdk: 1.4.2_16
Built-By: dlg01
Bundle-ManifestVersion: 2
Bundle-Name: commons-logging.commons-logging
Bundle-SymbolicName: commons-logging
Bundle-Version: 1.1.1.bnd-u8sQ6Q
Export-Package: org.apache.commons.logging;version="1.1.1",org.apache.co
 mmons.logging.impl;version="1.1.1";uses:="javax.servlet,org.apache.aval
 on.framework.logger,org.apache.commons.logging,org.apache.log,org.apach
 e.log4j"
Extension-Name: org.apache.commons.logging
Implementation-Title: Jakarta Commons Logging
Implementation-Vendor: Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 1.1.1
Import-Package: javax.servlet,org.apache.avalon.framework.logger,org.apache.log,org.apache.log4j
Originally-Created-By: Apache Maven
Specification-Title: Jakarta Commons Logging
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
X-Compile-Source-JDK: 1.2
X-Compile-Target-JDK: 1.2

from bnd-platform.

stempler avatar stempler commented on August 24, 2024

Strange, the configuration looks alright. Does it make a difference if you use org.apache.avalon.framework.logger.* or org.apache.avalon.framework.* for the optional import instruction?

from bnd-platform.

ocroquette avatar ocroquette commented on August 24, 2024

Hmmm, no, it doesn't.

I also tried this as a cross check:

      optionalImport 'javax.servlet'

It doesn't have any effect either.

from bnd-platform.

stempler avatar stempler commented on August 24, 2024

Just copied your build.gradle and let it run locally, this is the Manifest I get:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Build-Jdk: 1.4.2_16
Built-By: dlg01
Bundle-ManifestVersion: 2
Bundle-Name: commons-logging.commons-logging
Bundle-SymbolicName: commons-logging
Bundle-Version: 1.1.1.bnd-5zkmsg
Export-Package: org.apache.commons.logging;version="1.1.1",org.apache.co
 mmons.logging.impl;version="1.1.1";uses:="javax.servlet,org.apache.aval
 on.framework.logger,org.apache.commons.logging,org.apache.log,org.apach
 e.log4j"
Extension-Name: org.apache.commons.logging
Implementation-Title: Jakarta Commons Logging
Implementation-Vendor: Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 1.1.1
Import-Package: org.apache.avalon.framework.logger;resolution:=optional,
 javax.servlet,org.apache.log,org.apache.log4j
Originally-Created-By: Apache Maven
Specification-Title: Jakarta Commons Logging
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
X-Compile-Source-JDK: 1.2
X-Compile-Target-JDK: 1.2

So everything seems to work fine. Maybe an issue with the Gradle version? I just used Gradle 2.4, after that I tried it with Gradle 3.1, with the same result.

from bnd-platform.

stempler avatar stempler commented on August 24, 2024

Strange though that the hash is different than yours - this would hint at a different configuration. Did you maybe look into an old Jar?
Maybe also run the clean task, e.g. gradle clean updateSite

from bnd-platform.

ocroquette avatar ocroquette commented on August 24, 2024

I deleted ~/.groovy, ~/.gradle, killed all daemons etc., and now it works as expected, both with Gradle 2.9 that I used in the first place, and 3.1. So I guess something was wrong with my environment. Strangely enough, I had the same symptoms on my Mac and on a Windows PC. I fixed it on my Mac, I will check on Windows on monday.

During the many trials and errors, I also had an error message during the Eclipse download like the one in this bug report:
michel-kraemer/gradle-download-task#47
It's gone now. It was also probably due to environment/caches, maybe it's related to the original issue I had.

Feel free to close the issue. Thanks again for your help.

from bnd-platform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.