Hi guys,
We have found two issues regarding the download of test sources from the
remote repository.
1. "test vs tests" artifact source classifier for test
This first issue actually involves several maven plugins whilst
deploying an artifact.
First of all, the maven-jar-plugin generates into the remote repository
a file named xxx-tests.jar.
Then the maven-source-plugin generates another file named
xxx-test-sources.jar (notice that test doesn't ends with "s")
Finally, the maven-idea-plugin tries to download the artifact called
xxx-tests-sources.jar (which doesn't exist in the remote repository)
It seems to us that there is a bit of confusion with the suffix of the
classifier (test vs tests).
Have you guys already noticed such behaviour?
2. Incorrect artifact sources download
Once we have noticed the issue explained above, we have tried to fix by
renaming the xxx-test-sources.jar into xxx-tests-sources.jar but the
maven-idea-plugin downloaded the xxx-test-sources.jar with the contents
of the actual sources from the artifact (xxx-sources.jar)
The bug is located in the metod resolveClassifiedArtifact from the class
IdeaModuleMojo. Below our fix to the problem (see the dirty fix line):
Thanks
Boris and Fede
private String resolveClassifiedArtifact( Artifact artifact, String
classifier )
{
String basePath = artifact.getFile().getAbsolutePath().replace(
'\\', '/' );
int delIndex = basePath.indexOf( ".jar" );
if ( delIndex < 0 )
{
return null;
}
List remoteRepos =
executedProject.getRemoteArtifactRepositories();
try
{
// Dirty fix AGF: the classifier contains "tests-sources",
we change it by "test-sources"
String remoteClassifier = classifier;
if ("tests".equals(artifact.getClassifier())) {
remoteClassifier = "test-sources";
delIndex -= 1; // remove s of 'tests'
}
Artifact classifiedArtifact =
artifactFactory.createArtifactWithClassifier( artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
artifact.getType (),
remoteClassifier );
String dstFilename = basePath.substring( 0, delIndex ) + '-'
+ classifier + ".jar";
// End of Dirty fix AGF
File dstFile = new File( dstFilename );
classifiedArtifact.setFile( dstFile );
//this check is here because wagonManager does not seem to
check if the remote file is newer
// or such feature is not working
if ( !dstFile.exists() )
{
wagonManager.getArtifact( classifiedArtifact,
remoteRepos );
}
return dstFile.getAbsolutePath().replace( '\\', '/' );
}
catch ( TransferFailedException e )
{
getLog().debug( e );
return null;
}
catch ( ResourceDoesNotExistException e )
{
getLog().debug( e );
return null;
}
}
------------------------------
Ce message est protege par les regles relatives au secret des correspondances;
il peut en outre contenir des informations a caractere confidentiel ou
protegees par differentes regles et notamment le secret des affaires; il est
etabli a destination exclusive de son destinataire. Toute divulgation,
utilisation, diffusion ou reproduction (totale ou partielle) de ce message, ou
des informations qu'il contient, doit etre prealablement autorisee.
Tout message electronique est susceptible d'alteration et son integrite ne peut
etre assuree. Les AGF declinent toute responsabilite au titre de ce message
s'il a ete modifie ou falsifie.
Si vous n'etes pas destinataire de ce message, merci de le detruire
immediatement et d'avertir l'expediteur de l'erreur de distribution et de la
destruction du message.
This message is protected by the secrecy of correspondence rules; furthermore
it may contain privileged or confidential information that is protected by law,
notably by the secrecy of business relations rule; it is intended solely for
the attention of the addressee. Any disclosure, use, dissemination or
reproduction (either whole or partial) of this message or the information
contained herein is strictly prohibited without prior consent.
Any electronic message is susceptible to alteration and its integrity can not
be assured. AGF declines any responsibility for this message in the event of
alteration or falsification.
If you are not the intended recipient, please destroy it immediately and notify
the sender of the wrong delivery and the mail deletion.
------------------------------