Thanks to Stephen Johnson <stejohns@redhat.com>
Details from the original email:
---------
The following patch stops builds failing when target/classes (or no main java exists), and target/test-classes and src/tests exist.
So for example calling
mvn test -> invokes compiler:compile and if you have export bound to process-classes phase in executions it will fail. Maybe better to give info and carry on. Say for example they want to leave the executions in place that deal with process-classes and also process-test-classes but they do not want it to fail if there is no java to annotate in src/classes. The other way would be to comment out the executions bound to process-classes. What about export being bound to process-class by default? Could this also cause issues?
In either case I think the plugin code did checks for src/classes directory existing, in which case even call "mvn test" would fail as src/classes would not exist as no java existed in src/main only in src/test. Have a look through the patch and see if its of any use.
<name>Eduard Szente</name>
<email>eduard.szente@gmail.com</email>
</contributor>
<name>Eduard Szente</name>
<email>eduard.szente@gmail.com</email>
</contributor>
+ <contributor>
+ <name>Stephen Johnson</name>
+ <email>stejohns@redhat.com</email>
+ </contributor>
</contributors>
<distributionManagement>
</contributors>
<distributionManagement>
- File dir = new File(outputDirectory);
- if (!dir.exists())
- throw new MojoExecutionException("Cannot scan for annotated classes in " + outputDirectory + ": directory does not exist!");
-
Map<String,String> md5s;
boolean modified = false;
File saved = new File(buildDirectory + File.separator + MD5S);
Map<String,String> md5s;
boolean modified = false;
File saved = new File(buildDirectory + File.separator + MD5S);
try
{
AnnotationDB db = new AnnotationDB();
try
{
AnnotationDB db = new AnnotationDB();
- getLog().info("Scanning directory " + outputDirectory + " for annotated classes...");
- URL dirUrl = dir.toURI().toURL();
- db.scanArchives(dirUrl);
+ File dir = new File(outputDirectory);
+ if (dir.exists())
+ {
+ getLog().info("Scanning directory " + outputDirectory + " for annotated classes...");
+ URL dirUrl = dir.toURI().toURL();
+ db.scanArchives(dirUrl);
+ }
if (scanTestClasses)
{
dir = new File(testOutputDirectory);
if (scanTestClasses)
{
dir = new File(testOutputDirectory);
- if (!dir.exists())
- throw new MojoExecutionException("Cannot scan for annotated test-classes in " + testOutputDirectory + ": directory does not exist!");
- getLog().info("Scanning directory " + testOutputDirectory + " for annotated classes...");
- dirUrl = dir.toURI().toURL();
- db.scanArchives(dirUrl);
+ if (dir.exists())
+ {
+ getLog().info("Scanning directory " + testOutputDirectory + " for annotated classes...");
+ URL dirUrl = dir.toURI().toURL();
+ db.scanArchives(dirUrl);
+ }
}
Set<String> classNames = new HashSet<String>();
}
Set<String> classNames = new HashSet<String>();