Hi all,
In a pom using a custom plugin I have some assemblies that are set as plugin
dependencies. The plugin creates platform-appropriate artifact requests. They
are resolved just fine, then the plugin unpacks them and uses them to enact
some native build methods.
The problem is, when one of these is a snapshot, the plugin doesn't bother to
check with the remote repository for an update snapshot. If it sees it in the
local repository, it simply goes about its business. Is this an acceptable
method for pulling in platform-specific native packages? If so, how can I get
the ArtifactResolutionRequest to check remote for an updated snapshot?
The dependencies look like this:
<dependency>
<groupId>org.some.group</groupId>
<artifactId>some-artifact</artifactId>
<version>3.0.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
In the plugin, additional dependencies are resolved with platform-specific
classifier and packaging type like this:
// packaging will be zip or tar.gz depending on OS
Artifact artifact = repositorySystem.createArtifactWithClassifier(
a.getGroupId(), a.getArtifactId(),
a.getVersion(),
packaging, classifier
);
Artifact resolvedArtifact = resolveArtifact(artifact);
Resolved using this method (simplified for this note):
private Artifact resolveArtifact(Artifact artifact) throws Exception
{
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(project.getRemoteArtifactRepositories());
ArtifactResolutionResult resolutionResult =
repositorySystem.resolve(request);
if (resolutionResult.isSuccess()) {
return artifact;
}
String message = "Failed to resolve artifact " + artifact;
throw new Exception(message);
return null;
}
I have also tried circumventing the work the plugin does to request the
dependencies by directly requesting them this way, where packagingType could be
tar.gz and classifier is arbitrary:
<dependency>
<groupId>org.some.group</groupId>
<artifactId>some-artifact</artifactId>
<version>3.0.0-SNAPSHOT</version>
<classifier>${envClassifier}</classifier>
<type>${packagingType}</type>
</dependency>
When I have these in the top-level POM, the updated packages are always
correctly loaded as I'd expect them to be (unlike the former method, which
would check for a snapshot if it isn't in the local, but will never check for
updated snapshots with same version), but I can't figure out how to tell the
plugin that a new snapshot has been downloaded so it knows to do the additional
initialization to get the native packages ready for use. So, I know the former
method is perhaps "too magic", this method seems verbose but I can't get either
to work completely.
Thanks!
Patrick