Skip to content

Honour Maven offline mode in karaf-maven-plugin assembly and verify goals - #3152

Open
ponziani wants to merge 1 commit into
apache:mainfrom
ponziani:karaf-maven-plugin-offline
Open

ponziani wants to merge 1 commit into
apache:mainfrom
ponziani:karaf-maven-plugin-offline

Conversation

@ponziani

Copy link
Copy Markdown
Contributor

Fixes #3151.

The assembly and verify goals now pass Maven offline mode (mvn -o) to their Maven resolver. @jbonofre asked to split this out of #2979 in its review.

Changes

  • Builder: the offline key is now pid + ".offline" (the dot was missing). The configuration moved to mavenResolverConfiguration(pid), so a test can check it.
  • VerifyMojo: puts maven.offline=true in the resolver configuration when Maven runs offline. The configuration moved to the static resolverConfiguration(...) for the same reason.

Behaviour change

Until now, the resolver of both goals stayed online under -o. Now:

  • a bundle that is only referenced from a features file and is not in the local repository makes the build fail, instead of being downloaded;
  • an artifact cached under a different repository id (_remote.repositories says nexus, the resolver uses central) fails with "Cannot access central ... in offline mode and the artifact has not been downloaded from it before".

Release note: The karaf-maven-plugin assembly and verify goals now honour Maven offline mode (-o). Offline builds that relied on the plugin downloading missing artifacts must run online once first.

Tests

  • BuilderTest#testMavenResolverConfiguration and VerifyMojoTest#testResolverConfiguration check the offline key.

  • New invoker IT test-assembly-offline runs three builds:

    1. clean package online, which fills the local repository;
    2. -o -Pmissing-bundle package, which adds a bundle that is not in the local repository: the build must fail. verify.bsh checks that the bundle was not downloaded and that build.log has an offline-mode error for it;
    3. -o clean package: the offline assembly must succeed.

    It uses the released framework 4.4.11 KAR, because the SNAPSHOT KAR of this build is only built after the plugin. That is also why the existing assembly ITs are excluded.

    The IT is excluded from the test-offline invoker execution, because that execution replaces its invoker.properties (so it would only run a plain package).

  • The verify goal has no offline IT: VerifyMojoTest only checks the configuration it passes to the resolver.

Results:

  • With this change, the IT passes.
  • As a control, I put the old pid + "offline" key back in Builder. Then the IT fails at step 2: the -o build succeeds and downloads commons-csv-1.12.0.jar.

Backport

The missing dot dates from KARAF-3968 (Karaf 4.0.2), so karaf-4.4.x has the same bug (there the key is ORG_OPS4J_PAX_URL_MVN_PID + "offline"). I can open a backport PR if you want the fix there too.

🤖 Generated with Claude Code

…oals

The offline key of the assembly resolver missed its dot since KARAF-3968,
and the verify goal never passed maven.offline to its resolver.

Fixes apache#3151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

karaf-maven-plugin assembly and verify goals ignore Maven offline mode (-o)

1 participant