Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maven.multiModuleProjectDirectory in <repositories> not resolved #666

Closed
GaZaTu opened this issue May 4, 2022 · 24 comments
Closed

maven.multiModuleProjectDirectory in <repositories> not resolved #666

GaZaTu opened this issue May 4, 2022 · 24 comments

Comments

@GaZaTu
Copy link

GaZaTu commented May 4, 2022

yo,

i have a root pom.xml with an entry like this:

<repositories>
  <repository>
    <id>local-maven-repo</id>
    <url>file:///${maven.multiModuleProjectDirectory}/.local-maven-repo</url>
  </repository>
</repositories>

to provide all child maven modules with access to that in-project maven repo.

This works with IntelliJ and mvn-cli and used to work with Eclipse 2021-09 and redhat.java v1.1.0 but since updating to 2022-03 it results in an exception like this:

Failed to read artifact descriptor for GROUP_ID:ARTIFACT_ID:jar:0.0.1-SNAPSHOT

org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for GROUP_ID:ARTIFACT_ID:jar:0.0.1-SNAPSHOT
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:538)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:523)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:410)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:362)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.process(DefaultDependencyCollector.java:349)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:284)
	at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:169)
	at org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:227)
	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:200)
	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:124)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.readMavenProject(MavenImpl.java:649)
	at org.eclipse.m2e.core.internal.project.registry.DefaultMavenDependencyResolver.resolveProjectDependencies(DefaultMavenDependencyResolver.java:65)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refreshPhase2(ProjectRegistryManager.java:544)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.lambda$3(ProjectRegistryManager.java:508)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:156)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:506)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:358)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:312)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:413)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$1(ProjectConfigurationManager.java:362)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:156)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:103)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1411)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:361)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:347)
	at org.eclipse.jdt.ls.core.internal.managers.MavenBuildSupport.update(MavenBuildSupport.java:87)
	at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager$3.runInWorkspace(ProjectsManager.java:396)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: GROUP_ID:ARTIFACT_ID:pom:0.0.1-SNAPSHOT failed to transfer from file:///${maven.multiModuleProjectDirectory}/.local-maven-repo during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of local-maven-repo has elapsed or updates are forced. Original error: Could not transfer artifact GROUP_ID:ARTIFACT_ID:pom:0.0.1-SNAPSHOT from/to local-maven-repo (file:///${maven.multiModuleProjectDirectory}/.local-maven-repo): Repository path /${maven.multiModuleProjectDirectory}/.local-maven-repo does not exist, and cannot be created.
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:240)
	... 33 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: GROUP_ID:ARTIFACT_ID:pom:0.0.1-SNAPSHOT failed to transfer from file:///${maven.multiModuleProjectDirectory}/.local-maven-repo during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of local-maven-repo has elapsed or updates are forced. Original error: Could not transfer artifact GROUP_ID:ARTIFACT_ID:pom:0.0.1-SNAPSHOT from/to local-maven-repo (file:///${maven.multiModuleProjectDirectory}/.local-maven-repo): Repository path /${maven.multiModuleProjectDirectory}/.local-maven-repo does not exist, and cannot be created.
	at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:225)
	at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:189)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:573)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:483)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
	... 36 more
Java(0)

obscured GROUP_ID and ARTIFACT_ID

OS: openSUSE 15.1
IDE: both Eclipse 2022-03 and VSCode with redhat.java v1.5.0

@GaZaTu GaZaTu changed the title maven.multiModuleProjectDirectory in <repositories>...</...> is empty maven.multiModuleProjectDirectory in <repositories> not resolved May 4, 2022
@mickaelistria
Copy link
Contributor

Do I get it right the issue seems to be that ${maven.multiModuleProjectDirectory} is not expanded to its actual value?

@GaZaTu
Copy link
Author

GaZaTu commented May 4, 2022

I don't think it's expanded at all looking at this message in the exception:
...Repository path /${maven.multiModuleProjectDirectory}/.local-maven-repo does not exist, and cannot be created.

@mickaelistria
Copy link
Contributor

Do I get it right that this cause your project to be build-able only if starting it from its root; so it's basically not a modular build?

@laeubi
Copy link
Member

laeubi commented May 16, 2022

@mickaelistria see https://maven.apache.org/docs/3.3.1/release-notes.html#jvm-and-command-line-options the maven.multiModuleProjectDirectory is the first parent directory starting from the current executed module that has a .mvn folder so it could even be used if not executed from the root.

Just as an reference here https://stackoverflow.com/questions/29778262/what-is-maven-multimoduleprojectdirectory-used-for it is is noted that

This variable is only used in the mvn script and is neither documented nor intended for public used (internal implementation detail). So I strongly recommend not to use it. Otherwise things might break in the future.

@GaZaTu
Copy link
Author

GaZaTu commented May 16, 2022

I'll provide a smol example project in a bit 😋 but to answer the question: the errors are visible when opening the root project and it is indeed a modular project.

@mickaelistria
Copy link
Contributor

maven.multiModuleProjectDirectory is the first parent directory starting from the current executed module that has a .mvn folder so it could even be used if not executed from the root.

OK, thanks for clarifying. I see this variable is set by the MavenCli / CliRequest , that m2e doesn't use at all. So we'll need to replicate it.

@laeubi
Copy link
Member

laeubi commented May 16, 2022

yes, but setting this will first require to have project specific IMaven instances (or more formally, one instance per multiModuleProjectDirectory) to work properly, or we need to calculate this when creating an execution request for a project.

@mickaelistria
Copy link
Contributor

I don't think we need project-specific Maven instance, but we need to improve how we build the MavenExecutionRequest to set this location when it's relevant.

@laeubi
Copy link
Member

laeubi commented May 16, 2022

Possibly yes, when doing so it would be good to support maven.config and jvm.config as well see

@mickaelistria
Copy link
Contributor

I can try to work on this one if it's OK with you.

when doing so it would be good to support maven.config and jvm.config as well see

Later, in another issue ;)

@laeubi
Copy link
Member

laeubi commented May 16, 2022

Sure go a head, I just wanted to note that these two are very close related, once we have the multiModuleProjectDirectory populated it seems logical to also read the maven.config as this is the most relevant (beside extensions) and update the user-config accordingly.

mickaelistria added a commit to mickaelistria/m2e-core that referenced this issue May 16, 2022
This allows to read and set project-specific properties that can be
passed to the Maven request and used for
further executions.

Covers parts of eclipse-m2e#666 and
progress towards eclipse-m2e#546
mickaelistria added a commit to mickaelistria/m2e-core that referenced this issue May 16, 2022
This allows to read and set project-specific properties that can be
passed to the Maven request and used for
further executions.

Covers parts of eclipse-m2e#666 and
progress towards eclipse-m2e#546
@mickaelistria
Copy link
Contributor

@GaZaTu I've started to work on a patch that is likely to enable a lot of possible improvements, and even to fix the bug you mention. However, to be sure about the later, can you please share a minimal project that does reproduce the issue?

mickaelistria added a commit to mickaelistria/m2e-core that referenced this issue May 16, 2022
This allows to read and set project-specific properties that can be
passed to the Maven request and used for
further executions.

Covers parts of eclipse-m2e#666 and
progress towards eclipse-m2e#546
mickaelistria added a commit to mickaelistria/m2e-core that referenced this issue May 16, 2022
This allows to read and set project-specific properties that can be
passed to the Maven request and used for
further executions.

Covers parts of eclipse-m2e#666 and
progress towards eclipse-m2e#546
mickaelistria added a commit that referenced this issue May 16, 2022
This allows to read and set project-specific properties that can be
passed to the Maven request and used for
further executions.

Covers parts of #666 and
progress towards #546
@mickaelistria
Copy link
Contributor

@GaZaTu I merged a PR that is supposed to fix it. Please try updating to newer m2e snapshot in the next ~20 minutes and verify whether this is now working for you.

@GaZaTu
Copy link
Author

GaZaTu commented May 16, 2022

uhh i'm sorry @mickaelistria i left work some time ago and don't have any build env / project at hand rn 😅.
But tbh i wouldn't even know how to update my m2e snapshot anyway.

@mickaelistria
Copy link
Contributor

i left work some time ago

No need to be sorry for that, it's not some high emergency; enjoy your time away from work!

I wouldn't even know how to update my m2e snapshot anyway

Please see https://github.com/eclipse-m2e/m2e-core/blob/master/CONTRIBUTING.md#-trying-latest-builds to get some instructions about installing latest snapshots.

@laeubi
Copy link
Member

laeubi commented May 17, 2022

Should we close this and open dedicated issues if there is more work to do?

@mickaelistria
Copy link
Contributor

Let's wait for @GaZaTu to verify it befotlre closing.

@GaZaTu
Copy link
Author

GaZaTu commented May 17, 2022

idk what i'm doing wrong, i even downloaded a fresh eclipse-ide, but i just can't get this damn "Install new Software" dialog to open (which i assume is where i need to input https://download.eclipse.org/technology/m2e/snapshots/latest/).
Getting the following dialog message: Cannot complete the request. This installation has not been configured properly for Software Updates. See the error log for details and the error log: Could not locate the running profile instance. The eclipse.p2.data.area and eclipse.p2.profile properties may not be set correctly in this application's config.ini file.
I checked the config.ini but those properties were set. Also tried deleting the p2 directory or running eclipse -clean.
(╯°□°)╯︵ ┻━┻

@mickaelistria
Copy link
Contributor

@GaZaTu You seem to be unlucky here. Can you please try by downloading the Eclipse SDK from https://download.eclipse.org/eclipse/downloads/drops4/R-4.23-202203080310/ ?

@GaZaTu
Copy link
Author

GaZaTu commented May 17, 2022

OK atleast i'm able to open the "Install new Software" dialog, but now i'm stuck trying to install m2e.
Getting the following error message:

Cannot complete the install because one or more required items could not be found.
  Software being installed: M2E - Maven Integration for Eclipse (includes Incubating components) 2.0.0.20220516-1755 (org.eclipse.m2e.feature.feature.group 2.0.0.20220516-1755)
  Missing requirement: M2E Maven POM File Editor 2.0.0.20220515-1604 (org.eclipse.m2e.editor 2.0.0.20220515-1604) requires 'osgi.bundle; org.eclipse.wst.sse.core 0.0.0' but it could not be found
  Cannot satisfy dependency:
    From: M2E - Maven Integration for Eclipse (includes Incubating components) 2.0.0.20220516-1755 (org.eclipse.m2e.feature.feature.group 2.0.0.20220516-1755)
    To: org.eclipse.equinox.p2.iu; org.eclipse.m2e.editor [2.0.0.20220515-1604,2.0.0.20220515-1604]

I assume i need to install some other dependency before i install m2e but i have no idea which one/where to get it.
😑

Edit: nvm figured it out or rather just installed a bunch of others until it worked.

@mickaelistria
Copy link
Contributor

On the Install Dialog, there is a "Manage Sites" button. Click it to add https://download.eclipse.org/releases/latest/ (which should contain most deps). Then try re-installing m2e.

@GaZaTu
Copy link
Author

GaZaTu commented May 17, 2022

Looks like this issue is fixed, atleast i'm not getting any error messages anymore.
Only thing i noticed is that ${maven.multiModuleProjectDirectory} is not expanded in Effective POM but idk if that's relevant.

@mickaelistria
Copy link
Contributor

Looks like this issue is fixed, atleast i'm not getting any error messages anymore.

Great, thanks for testing!

Only thing i noticed is that ${maven.multiModuleProjectDirectory} is not expanded in Effective POM but idk if that's relevant.

If you think it's worth it, please open a separate issue.

@GaZaTu
Copy link
Author

GaZaTu commented May 17, 2022

Thanks 😋👌

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

No branches or pull requests

3 participants