Git Product home page Git Product logo

Comments (13)

bmuschko avatar bmuschko commented on May 24, 2024

At the moment Gradle's Java plugin does not support the provided scope out-of-the-box. However, Gradle allows you to define your own configurations so you can model this yourself. You will find many examples on the Gradle forum.

The configuration provided is not necessarily related to the functionality of this plugin. I am going to close this issue.

from gradle-nexus-plugin.

felixbarny avatar felixbarny commented on May 24, 2024

Creating a provided configuration is easy, but how do I mark that dependency as provided in pom.xml? Isn't that related to this plugin?
I did not find a proper solution for this on the web yet. Could you point me to solution?

from gradle-nexus-plugin.

bmuschko avatar bmuschko commented on May 24, 2024

If you are consuming a published artifact that declares transitive dependencies with scope provided in its POM, Gradle will not resolve them. It would only be valuable if you need this for documentation purposes. Is that the use case?

from gradle-nexus-plugin.

felixbarny avatar felixbarny commented on May 24, 2024

I am trying to publish a artifact that has a provided dependency on javax.servlet-api and I want the <dependency> in the published pom to be <scope>provided</scope>.

from gradle-nexus-plugin.

bmuschko avatar bmuschko commented on May 24, 2024

If you really want to do that you can iterate over the dependencies assigned to the configuration provided and then modify the POM creation as shown in 53.6.4. Maven POM generation of the user guide. You can probably do that in the modifyPom closure of this plugin as well. I'd have to have a deeper look.

from gradle-nexus-plugin.

felixbarny avatar felixbarny commented on May 24, 2024

you mean 53.7 in http://gradle.org/docs/current/userguide/maven_plugin.html? That results in this error: Could not find property 'mavenDeployer' on repository container.

If I'm just doing

        def installer = install.repositories.mavenInstaller

        [installer]*.pom*.whenConfigured { pom ->
            pom.dependencies.removeAll { dep -> dep.scope == 'test' }
            pom.dependencies.findAll {dep -> dep.artifactId == 'javax.servlet-api' }.each {
                it.scope = 'provided'; println it
            }
        }

The pom does not get modified, even though the println it prints out the correct dependency.

It would be so great if you could take a look on this. I think this and the possibility to mark a dependency as optional is quite important, don't you think? Or would it be ok in your opinion to just exclude those deps from the pom.xml?

Thank you for you support!

from gradle-nexus-plugin.

bmuschko avatar bmuschko commented on May 24, 2024

It would have to be coordinated with some internals of the plugin. I need to defer some evaluation order etc. as part of the implementation. modifyPom is something exposed by the Nexus plugin and not the Maven plugin. I am going to reopen this. At the moment I won't have to much time to look into this issue. If you want to tackle this, the right away of approach it would be to add an integration test to the plugin.

from gradle-nexus-plugin.

bmuschko avatar bmuschko commented on May 24, 2024

Here's an example that demonstrates how to make it work.

from gradle-nexus-plugin.

felixbarny avatar felixbarny commented on May 24, 2024

Awesome, thanks a lot!
But that's not quite it, because the pom won't contain compile dependencies anymore, so you have to add this snippet:

project.configurations.compile.allDependencies.each { dep ->
    dependency {
        groupId dep.group
        artifactId dep.name
        version dep.version
        scope 'compile'
    }
}

Also, I would slightly modify the provided configuration:

configurations {
    provided
    compile.extendsFrom provided
}

This way you don't get compile errors if you call a method from a provided dependency and IntellJ will automatically add the jar to the classpath.

from gradle-nexus-plugin.

bmuschko avatar bmuschko commented on May 24, 2024

I am probably overriding the generated dependencies POM metadata with my modification. I requires some additional tweaking. Next time I have some spare time I will fix it.

There are different ways to model the provided configuration. The test case only demonstrates that you can modify the POM. It's not supposed to demonstrate the "correct" usage of provided per se.

from gradle-nexus-plugin.

felixbarny avatar felixbarny commented on May 24, 2024

I just wanted to add this in case someone else has the same usecase as me.

from gradle-nexus-plugin.

bmuschko avatar bmuschko commented on May 24, 2024

Done. I also fixed the dependencies generation. BTW: Why don't you use the providedCompile configuration from the War plugin for your Servlet dependency?

from gradle-nexus-plugin.

felixbarny avatar felixbarny commented on May 24, 2024

Because I don't want to create a war but a jar. I'm the developer of a open source application performance monitoring project (www.stagemonitor.org). For the web agent I have to have a dependency to the servlet-api to get information about incoming requests, register the monitoring filter and inject a monitoring toolbar into the site's html.

from gradle-nexus-plugin.

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.