tycho
tycho copied to clipboard
`RemapArtifactToMavenRepositoriesMojo` fails when remote repositories are unreachable
I use this mojo in my build and I need to be able to build in offline mode without internet connection.
This mojo invokes the MirrorApplicationService
that look for artifacts in the remote repositories. However, it does not honor the --offline
flag and try to reach remote repositories and fail to build when they are not.
I have bypassed the issue by isolating the mojo execution into a dedicated profile that I can disable in my offline build, but I would appreciate a more robust implementation.
Adding the requiresOnline
flag to the mojo annotation could be an improvement, as it will skip the execution when the --offline
flag is set.
Best regards.
Can you provide an integration-test to demonstrate the issue? Actually Tycho should handle offline globally and I don't even see why RemapArtifactToMavenRepositoriesMojo
should require access to the update-site at all...
@rbioteau what behavior would you expect when being offline? A failure seems the most correct as mojo cannot perform anyway. If you just want to ignore it, then we could image a flag ignoreErrors
that you could enable. But overall, the idea of a profile to select whether to require execution or not does seem to be the best one.
@laeubi Remap does contact remote Maven repositories for p2 artifacts to check whether they contain an equivalent Maven Artifacts for the given p2 artifact: https://github.com/eclipse-tycho/tycho/blob/fd2527d74966f974f25e80b106912804b92a7d2d/tycho-core/src/main/java/org/eclipse/tycho/p2tools/MirrorApplicationServiceImpl.java#L378
In my use case the mojo execution is not mandatory, so being able to skip it (either using the requiresOnline
or using a configuration parameter -Dtycho.remapArtifactToMavenRepositories.skip
) would be handy. However, there might be use cases where not performing it would lead to errors in the consumer's update-sites I guess.
Feel free to submit a PR to add requiresOnline
, as it seems good to add it anyway/
Feel free to submit a PR to add
requiresOnline
, as it seems good to add it anyway/
I think a general <skip>
parameter is more suitable / maven like in this case, binding it to online/offline seems strange as indicated above I don't see how this should ever make a difference. We either should use the standard maven-resolver (that already should support online/offline) or skip the online check if one is working offline alltogether.
e.g. in offline mode one might simply check the local repository instead...
What I don't like with the requiresOnline
flag is that it will just skip the execution when offline without more information in the build output. As a user, I prefer seeing the mojo fail to analyze the impact of not executing it. Then, having a configuration flag to skip it seems relevant.
Using the standard maven-resolver is relevant, but then you still have to choose what behavior to adopt when offline mode is enabled (fail, warning logs, ignore silently..etc)
in offline mode one might simply check the local repository instead.
What kind of remapping do you apply then ? Do you remap to the artifact local repository path ? It could work to a certain point, but you'll lose the portability of the generated update site.
The online check is only performed to see if the artifact is a "real" maven artifact. "remapping" of artifacts is in general fragile and I won't recommend it, I even don't know any project actually using it and instead one should use real maven-p2 update sites if desired especially if portability is an issue for you.