This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270552 - Timestamped snapshots incorrectly resolved to project sources
Summary: Timestamped snapshots incorrectly resolved to project sources
Status: NEW
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: Dev
Hardware: PC Linux
: P3 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2017-05-03 22:46 UTC by Jesse Glick
Modified: 2018-04-16 14:08 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch with some successful testing (8.31 KB, patch)
2017-05-03 23:02 UTC, Jesse Glick
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2017-05-03 22:46:21 UTC
Maven lets you `deploy` snapshot builds of an upstream component, then give a timestamped snapshot version as the dependency version in a downstream component’s POM. This works fine for command-line builds: the exact requested version will be downloaded to the local repository on demand and used, ignoring any other locally `install`ed snapshot builds.

But it does not work as expected in the NetBeans editor; if the IDE has a record of the source location of the upstream project (as is likely), it will try to associate the dependency with the source project. So long as you have not made any changes to the upstream project since deployment, this may be OK, but if you have—for example, switched the upstream sources back to trunk from a branch—the IDE will treat the current source project as authoritative (`preferSources`), potentially leading to error badges and the like in the downstream project’s source files, even though they are buildable by `mvn`.

Using `apisupport.projectinspector` I found that this is not a problem with `MavenForBinaryQueryImpl` per se; it is correctly reporting a source association for something like `~/.m2/repo/grp/art/1.0-SNAPSHOT/art-1.0-SNAPSHOT.jar`. The problem is that `CompileClassPathImpl` is reporting that as the dependency artifact’s file, while in reality it is something like `~/.m2/repo/grp/art/1.0-SNAPSHOT/art-1.0-20170503.012345-1.jar` (which `MavenForBinaryQueryImpl` rightly ignores).

This bug makes it complicated and confusing to use timestamped snapshots in complex chains of multimodule branchy development.
Comment 1 Jesse Glick 2017-05-03 23:01:17 UTC
I have a patch which fixes it up the use site. Better would be for the resolved file to be correct to begin with, but at least in `apache/maven` it seems `DefaultArtifact` calls `DefaultRepositoryLayout` which always uses `baseVersion`, ignoring version; unclear what happens differently in command-line builds that lets it work. I suspect that newer Maven versions in `apache/maven-resolver` (formerly Aether) in `DefaultArtifactResolver.getFile` leave the file alone unless `aether.artifactResolver.snapshotNormalization` is enabled. I suspect NetBeans’s `maven.embedder` is just so obsolete that it is still using logic dating to Maven 2.x which command-line `mvn` has long since abandoned.
Comment 2 Jesse Glick 2017-05-03 23:02:06 UTC
Created attachment 164239 [details]
Patch with some successful testing