Hi Stephen,
> did you remember to add a -U to your command line to force maven to
> recheck for newer plugin versions?
>
Cool, thanks, running it with "-U" avoids the problem.
So, that leads to a feature request: when running
versions:display-plugin-updates, it would be nice to receive a warning when
"-U" is not specified, indicating that the detected plugin versions may not
be the latest. I think it is unintuitive to need this flag, since the long
name is --update-snapshots but the display-plugin-updates goal reports
newer *release* versions.
I played in the code some more hoping to create a patch. My plan was to add
a simple if/then block at the beginning of
DisplayPluginUpdatesMojo#execute() that simply prints a warning to the log
if "-U" wasn't specified. Something like:
for ( final Object item : remotePluginRepositories )
{
final ArtifactRepository remotePluginRepo =
(ArtifactRepository) item;
if (
!remotePluginRepo.getReleases().getUpdatePolicy().equals(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS)
)
{
getLog().warn( "Reported versions may not be the latest;
try again with -U flag. Repo = " + remotePluginRepo );
break;
}
}
Unfortunately, even with -U set, it still generates the message:
[WARNING] Reported versions may not be the latest; try again with -U flag.
Repo = id: central
url: http://repo.maven.apache.org/maven2
layout: default
snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => never]
So I give up for now. Personally I'll remember to put -U in the future for
myself; I just thought it would be nice to warn other noobs about it too.
Regards,
Curtis
On Wed, May 30, 2012 at 2:58 AM, Stephen Connolly <
[email protected]> wrote:
> did you remember to add a -U to your command line to force maven to
> recheck for newer plugin versions?
>
> On 29 May 2012 21:36, Curtis Rueden <[email protected]> wrote:
> > Hi Stephen & everyone,
> >
> > After seeing the release announcement for maven-compiler-plugin 2.5
> (yay), I
> > thought I would update the plugin versions in my toplevel organization
> POM.
> > So naturally I ran "mvn versions:display-plugin-updates". However, I was
> > surprised to see that it still detected version 2.3.2 as the latest
> version
> > of maven-compiler-plugin.
> >
> > I mocked up a little example that demonstrates:
> > https://gist.github.com/2830363
> >
> > The problem occurs with Maven 3.0.4, but not with Maven 2.2.1.
> >
> > I dove into the source code of versions-maven-plugin a bit to try and
> debug:
> >
> > The problem seems to come down to a method call in:
> >
> >
> org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupArtifactVersions(
> > Artifact artifact, boolean usePluginRepositories )
> >
> > Specifically:
> >
> > ArtifactVersions artifactVersions = new ArtifactVersions(
> artifact,
> >
> > artifactMetadataSource.retrieveAvailableVersions( artifact,
> localRepository,
> > remoteRepositories ),
> > getVersionComparator( artifact ) );
> >
> > Variable values are:
> >
> > artifactVersions =
> >
> ArtifactVersions{artifact=org.apache.maven.plugins:maven-compiler-plugin:maven-plugin:2.3.1:runtime,
> > versions=[2.0-beta-1, 2.0, 2.0.1, 2.0.2, 2.1, 2.2, 2.3, 2.3.1, 2.3.2],
> >
> versionComparator=org.codehaus.mojo.versions.ordering.MavenVersionComparator@256f8834
> }
> > localRepository = id: local
> > url: file:///Users/curtis/.m2/repository/
> > layout: none
> >
> > remoteRepositories = [ id: central
> > url: http://repo.maven.apache.org/maven2
> > layout: default
> >
> > So really the problem is in Maven core, in
> >
> maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> > in the retrieveAvailableVersions methods. Before digging any deeper I
> > figured I'd ask on this list.
> >
> > However, I did look on Maven Central
> > (
> http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/
> )
> > and all seems to be in order there: versions 2.4 and 2.5 exist as
> expected.
> > I also checked my local repository cache and found version 2.5 sitting
> there
> > too (not 2.4, since my projects have never referenced it).
> >
> > Any ideas on what could be the problem? Am I missing something obvious?
> Is
> > this a bug?
> >
> > I'm paranoid now, wondering whether any of my other plugin versions are
> out
> > of date, and versions-maven-plugin isn't telling me...
> >
> > Thanks,
> > Curtis
> >
>