elharo opened a new pull request, #394:
URL: https://github.com/apache/maven-antrun-plugin/pull/394

   `org.apache.maven.artifact.repository.ArtifactRepository` is deprecated. Its 
javadoc says:
   
   > Avoid use of this type, if you need access to local repository use 
repository system classes instead.
   
   This does that. The local repository now comes from the 
`RepositorySystemSession`, which is available on every Maven version this 
plugin supports (`maven` prerequisite is 3.6.3, and 
`${repositorySystemSession}` plus 
`RepositorySystemSession#getLocalRepository()` / `#getLocalRepositoryManager()` 
all exist in the resolver version shipped with it).
   
   The deprecated type was used in three places, so all three are affected.
   
   ## `DependencyFilesetsTask`
   
   The `maven.local.repository` Ant reference now holds an 
`org.eclipse.aether.repository.LocalRepository`. `LocalRepository` has no 
path-computation method, so a second reference, 
`maven.local.repository.manager`, exposes the `LocalRepositoryManager` for 
`getPathForLocalArtifact()`.
   
   `ArtifactRepository#pathOf()` has no direct equivalent on `LocalRepository`, 
so the task now calls 
`LocalRepositoryManager#getPathForLocalArtifact(RepositoryUtils.toArtifact(artifact))`.
 These apply the same layout rules, including the SNAPSHOT case where the 
directory uses the base version but the filename uses the resolved version.
   
   ## The two Ant properties
   
   - `${settings.localRepository}` — **unchanged**, still the absolute path of 
the local repository.
   - `${localRepository}` — **value changes.** It was 
`ArtifactRepository#toString()`, a multi-line debug dump whose first line read 
`id: local`; it is not usable as a path. It is now the same absolute path that 
`${settings.localRepository}` provides.
   
   Neither property is documented on the site, and `local-repo-prop-test` only 
asserts they are set, but this is visible to anyone referencing 
`${localRepository}`.
   
   ## Other change
   
   The `@Parameter(property = "localRepository")` hook went away with the 
field. It allowed `-DlocalRepository=...` to override the repository the plugin 
used, which cannot be expressed as a repository system session, and was not 
documented.
   
   ## Verification
   
   - Before: 4 deprecation warnings for `ArtifactRepository` (the import and 
field in `AntRunMojo`, the import and local-variable type in 
`DependencyFilesetsTask`). After: none. The two remaining warnings are the 
unrelated `org.codehaus.plexus.util.ReaderFactory` ones.
   - `mvn clean verify`: BUILD SUCCESS, 0 Checkstyle violations, Spotless 
clean, 4/4 unit tests.
   - All 29 ITs pass via `mvn invoker:install invoker:run`.
   - To check that swapping `pathOf()` for `getPathForLocalArtifact()` resolves 
the same files, I built the same project against the old and new plugin and 
copied out the `maven.project.dependencies` fileset. The resulting trees are 
**identical** (41 files), covering the cases where the two could have diverged: 
a release, a SNAPSHOT, a classifier (`json-lib:2.4:jdk15`), a `pom`-typed 
dependency, and a `classes`-extension artifact.
   
   ## Note for maintainers
   
   The `protected ArtifactRepository localRepository` field became a `protected 
LocalRepository getLocalRepository()` method, and the Ant reference type 
changed. Both are breaking for anyone subclassing `AntRunMojo` or reading 
`maven.local.repository` as an `ArtifactRepository` from a custom Ant task. 
That seemed unavoidable given the type is deprecated, but flagging it in case a 
`@Deprecated`-and-removed cycle is preferred.
   
   `ReaderFactory` is also deprecated (2 warnings) and could be dealt with in a 
follow-up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to