jenkins.io icon indicating copy to clipboard operation
jenkins.io copied to clipboard

Update parent POM - Added a Maven configuration

Open Giridharan002 opened this issue 2 years ago • 10 comments

Added a Maven configuration (settings.xml) in the Update parent POM (Documentation)

Configure "settings.xml" for successful maven-hpi-plugin development.

  • [X] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • [X] Ensure that the pull request title represents the desired changelog entry
  • [X] Please describe what you did

Giridharan002 avatar Mar 05 '23 17:03 Giridharan002

Ideally this information should be in plugin POM and not your local settings -- that way anybody can build the plugin without the need for extra setup. See how e.g. https://github.com/jenkinsci/git-plugin/blob/master/pom.xml#L263 embeds the repository settings

For the <mirrors> setting I'm not sure when it's useful/needed.

zbynek avatar Mar 05 '23 20:03 zbynek

as far as I know the only thing that is helpful there is adding:

  <pluginGroups>
    <pluginGroup>org.jenkins-ci.tools</pluginGroup>
  </pluginGroups>

which all it does is help maven resolve the hpi plugin and prevents it from logging a warning to the build.

the rest should be unneeded

timja avatar Mar 05 '23 22:03 timja

I've understood the same that @timja has, that there should not be a need for the additional settings.xml file. @Giridharan002 can you provide examples of plugins that require the settings.xml file in order to update the parent pom?

MarkEWaite avatar Mar 05 '23 23:03 MarkEWaite

  • Thank you for your question.

I apologize for any confusion my previous response may have caused.

Upon further research, I have learned that the additional settings.xml file is not required for updating the parent pom, it should be done by modifying the 'pom.xml' file directly.

Again, I apologize for any confusion.

Giridharan002 avatar Mar 06 '23 02:03 Giridharan002

I've understood the same that @timja has, that there should not be a need for the additional settings.xml file. @Giridharan002 can you provide examples of plugins that require the settings.xml file in order to update the parent pom?

After reviewing my previous response, I would like to clarify that the use of a "settings.xml" file may be necessary in certain cases when updating a parent POM, particularly if the project has custom repository configurations or requires authentication. In fact, as mentioned by you and Darin Pope in the "Modernizing Jenkins Plugins" video (https://www.youtube.com/live/Fev8KfFsPZE?feature=share), the Scheduled Build Plugin requires a separate "settings.xml" file to update a parent POM.

Therefore, if a user wants to use the Scheduled Build Plugin to trigger Maven builds that involve updating a parent POM, they may need to configure the "settings.xml" file to include any custom repository locations or authentication details.

Giridharan002 avatar Mar 07 '23 13:03 Giridharan002

Hi @kmartens27,

Thank you for reviewing the text and providing suggestions for formatting and syntax. I'm glad to hear that the documentation is clear overall. I will definitely take your suggestions into consideration and make any necessary adjustments.

Just to clarify, do you mean that I should make the changes you mentioned and then resend the pull request?

Thanks again for your help!

Giridharan002 avatar Mar 07 '23 13:03 Giridharan002

Hi @Giridharan002 when making changes, you would do as you said and make the changes locally on the same branch and then push the changes in a new commit to the same pull request.

Other than that, I would update the text according to the insights provided by @MarkEWaite & @timja and add the commit at that point.

kmartens27 avatar Mar 07 '23 14:03 kmartens27

@Giridharan002 there are 2 problems this is trying to solve:

  • artifacts not downloaded during build: I think the tutorial should suggest adding the <repositories> and <pluginRepositories> sections to the plugin POM (not to setttings)
  • resolution of the HPI plugin as mentioned in https://github.com/jenkins-infra/jenkins.io/pull/6113#issuecomment-1455228348 -- that part could be in the settings. Since this is not specific to the tutorial, maybe it could go to a different page, e.g. https://www.jenkins.io/doc/developer/development-environment/ide-configuration/ like #6109 suggests

zbynek avatar Mar 18 '23 07:03 zbynek

Hi @Giridharan002, I wanted to check and see if this is still something you are working on. It appears that @zbynek had provided some feedback, but it has been a bit since there was any further action. If there is anything that you have questions or concerns about, let us know!

kmartens27 avatar Apr 24 '23 16:04 kmartens27

as far as I know the only thing that is helpful there is adding:

  <pluginGroups>
    <pluginGroup>org.jenkins-ci.tools</pluginGroup>
  </pluginGroups>

which all it does is help maven resolve the hpi plugin and prevents it from logging a warning to the build.

the rest should be unneeded

I did some more detailed testing and came to a different conclusion than @timja. I may be making a mistake somehow in my configuration, but here is what I observed:

No /.m2/settings.xml file

When I compile the embeddable build status plugin or a new plugin created from the archetype, I get a warning in the compiler output that says:

[INFO] Scanning for projects...
[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:3.38 is missing, no dependency information available
[WARNING] Failed to build parent project for org.jenkins-ci.plugins:embeddable-build-status:hpi:999999-SNAPSHOT

Only pluginGroups in settings.xml

When my ~/.m2/settings.xml contains only:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <pluginGroups>
    <pluginGroup>org.jenkins-ci.tools</pluginGroup>
  </pluginGroups>
</settings>

then the compilation of embeddable build status plugin reports the warning:

[INFO] Scanning for projects...
[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:3.38 is missing, no dependency information available
[WARNING] Failed to build parent project for org.jenkins-ci.plugins:embeddable-build-status:hpi:999999-SNAPSHOT

Include pluginRepository and pluginGroups in settings.xml

When my ~/.m2/settings.xml contains:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <pluginGroups>
    <pluginGroup>org.jenkins-ci.tools</pluginGroup>
  </pluginGroups>
  <profiles>
    <profile>
      <id>jenkins</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>repo.jenkins-ci.org</id>
          <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>repo.jenkins-ci.org</id>
          <url>https://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

then the compilation of embeddable build status plugin reports no warning.

I'm not skilled enough with Maven settings files to identify a minimum description of the settings that avoid the warning about maven hpi plugin, but as far as I can tell, more than the pluginGroups section is required.

@timja, any suggestions what's different between my configuration and yours?

MarkEWaite avatar Apr 25 '23 23:04 MarkEWaite

Please take a moment and address the merge conflicts of your pull request. Thanks!

github-actions[bot] avatar Apr 08 '24 16:04 github-actions[bot]

Superseded by:

  • #7194

Thanks for starting us down the path to resolve the issue!

MarkEWaite avatar Apr 08 '24 16:04 MarkEWaite