Skip to content

Maven configuration settings.xml #4263

Closed

Description

@ganigurgah

Description

Read maven settings.xml file from defined maven home property

When change Maven Home from Tools>Options>Java>Maven, IDE continues reading maven settings.xml file from .m2 directory.

It should Actually read configs from new defined Maven Home/conf/settings.xml

Activity

  1. added
    kind:feature
    needs:triage
    on Jun 21, 2022
  2. mbien commented on Jun 21, 2022

    @mbien
    Member

    Maven Home sets the path to maven. The .m2 directory is shared since it is the default which also means .m2/settings.xml is shared too.

    I don't see how changing Maven Home would influence what settings.xml is read.

  3. ganigurgah commented on Jun 23, 2022

    @ganigurgah
    Author

    There is conf/settings.xml under apache_maven directory. If I change the maven_home parameter from the IDE, I want it to read the settings from the new home too. Why am I forced to .m2 when I can change maven_home whenever I want?

  4. ebarboni commented on Jun 23, 2022

    @ebarboni
    Contributor

    settings.xml in maven home is supposed to be for all users on you computer.
    you have you personal .m2 containing your settings.xml

    personal + global are merged but personal take precedence. Remove settings.xml from you .m2 and you respect maven way of handling settings.
    IMHO We should not alter Maven way of managing settings.xml

    Edited to show rational from official documentation:
    https://maven.apache.org/settings.html Quick Overview section

  5. tbw777 commented on Jul 2, 2022

    @tbw777
    Contributor

    image

    but there is no

    -s,--settings
    -gs, --global-settings
    

    options in nb:

    image

  6. OndroMih commented on Jul 5, 2022

    @OndroMih
    Contributor

    I would change the description of this issue to allow setting path to the settings.xml globally in Maven settings (ideally also per project). IntelliJ Idea allows that and it's then possible to use different Maven settings (including a different local repository) for different projects if the settings collide (e.g. when working on projects for different clients)

  7. neilcsmith-net commented on Jul 5, 2022

    @neilcsmith-net
    Member

    @tbw777 did you try just adding the CLI options directly to the text field?

  8. OndroMih commented on Jul 7, 2022

    @OndroMih
    Contributor

    Adding -s option to the text field works in the sense that the build passes. But Netbeans shows a lot of errors in thr project view, because it's trying to find the dependencies in the standard local repo path where they don't exist. Repository in the services view also shows only the standard local repo.

  9. neilcsmith-net commented on Jul 7, 2022

    @neilcsmith-net
    Member

    @OndroMih The Services view also has an Add repository option that might be of use there. Not sure if there's anything that might get this configured on a per-project level though.

  10. todor-t commented on Mar 1, 2023

    @todor-t

    Adding -s option to the text field works in the sense that the build passes. But Netbeans shows a lot of errors in thr project view, because it's trying to find the dependencies in the standard local repo path where they don't exist. Repository in the services view also shows only the standard local repo.

    Also the settings.xml file show in Project Files seems to be hard coded to ~/.m2/settings.xml
    It would make more sense to show the one configured with -s option.
    Additionally it would be great if -s option can be set per Project Group. Currently it's only possible to set Maven Home.
    In any case NetBeans should use internally the same settings.xml as the maven build. And show it in Project Files, so it can be viewed or edited in NetBeans if necessary.

  11. added
    Maven
    and removed
    needs:triage
    on Aug 10, 2023
  12. Saljack commented on Nov 12, 2024

    @Saljack
    Contributor

    I also tried to configure a completely separate maven with a separated local repository. I use one maven configuration for the whole user it is in ~/.m2/settings then I have another maven and set in its settings.xml localRepository to a different folder. Then I override maven options with -s. Everything looks ok. I see local repository in in Maven Repositories and its artifacts. But the project is marked as unloadable and still tries to use artificats from ~/.m2/repository. It builds totally ok without any issue but Netbeans simply does not use localRepository configuration.

    The error is:

    1 problem was encountered while building the effective model for com.example.project-parent:1.0.1-SNAPSHOT
    [FATAL] Non-resolvable parent POM for com.example.project-parent:1.0.1-SNAPSHOT: The following artifacts could not be resolved: org.springframework.boot:spring-boot-starter-parent:pom:3.3.4 (present, but unavailable): Cannot access internal.repository (https://example.com/repository/maven-public/) in offline mode and the artifact org.springframework.boot:spring-boot-starter-parent:pom:3.3.4 has not been downloaded from it before. and 'parent.relativePath' points at no local POM
    

    If I click on Resolve Project Problems it builds everything and shows (but the project is still unloadable):
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Mavenkind:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions