For me the above fix didn't help, it deployed ok, but the classes are not
included into the final jars. I fixed the above problem as shown below. I
guess the fix is only needed for WAS60, and probably only in certain cases.
At least it works for me now.
Arthur
public void execute() throws MojoExecutionException,
MojoFailureException {
if (!getMavenProject().getPackaging().equalsIgnoreCase("ejb")) {
throw new MojoExecutionException(
"Invalid packaging type, this plugin
can only be applied to ejb
packaging type projects");
}
super.execute();
if (!getOutputJarFile().exists()) // TODO: Solve generically -
MWAS-14 -
// why doesn't failOnError fail the
// build and ws_ant return a
// returncode != 0?
{
throw new MojoExecutionException("Deployment failed -
see previous
errors");
}
File[] workingDirectorySubdirs =
getWorkingDirectory().listFiles(
(java.io.FileFilter)
DirectoryFileFilter.DIRECTORY);
if (workingDirectorySubdirs.length != 1) {
throw new MojoExecutionException("Cannot find workbench
root under "
+
getWorkingDirectory().getAbsolutePath());
}
File[] potentialRoots = workingDirectorySubdirs[0]
.listFiles((java.io.FileFilter)
DirectoryFileFilter.DIRECTORY);
if (potentialRoots.length > 2) {
throw new MojoExecutionException("Cannot find workbench
root under "
+
getWorkingDirectory().getAbsolutePath());
}
File workBenchRoot = null;
for (int i = 0; i < potentialRoots.length; i++) {
workBenchRoot = potentialRoots[i];
if (!workBenchRoot.getName().equals(".metadata")) {
break;
}
}
// copy sources
File generatedSources = new File(workBenchRoot, "ejbModule");
try {
// Create a filter for ".java" files
IOFileFilter javaSuffixFilter =
FileFilterUtils.suffixFileFilter(".java");
IOFileFilter javaFiles =
FileFilterUtils.andFileFilter(FileFileFilter.FILE, javaSuffixFilter);
FileFilter filter =
FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, javaFiles);
FileUtils.copyDirectory(generatedSources,
getGeneratedSourcesDirectory(),
filter);
FileUtils.deleteDirectory(new
File(getGeneratedSourcesDirectory(),
"META-INF"));
} catch (IOException e) {
throw new MojoExecutionException("Error copying
generated sources", e);
}
List compileSourceRoots =
getMavenProject().getCompileSourceRoots();
compileSourceRoots.add(getGeneratedSourcesDirectory().getPath());
// copy generated classes
File generatedClasses = new File(workBenchRoot, "ejbModule");
try {
// Create a filter for ".class" files
IOFileFilter classSuffixFilter =
FileFilterUtils.suffixFileFilter(".class");
IOFileFilter classFiles =
FileFilterUtils.andFileFilter(FileFileFilter.FILE, classSuffixFilter);
FileFilter filter =
FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, classFiles);
FileUtils.copyDirectory(generatedClasses,
getGeneratedClassesDirectory(),
filter);
Resource resource = new Resource();
resource.setDirectory(getGeneratedClassesDirectory().getPath());
getMavenProject().getResources().add(resource);
} catch (IOException e) {
throw new MojoExecutionException("Error copying
generated classes", e);
}
getLog().info("ejbDeploy finished");
}
--
View this message in context:
http://old.nabble.com/maven-ejb-plugin---was6-maven-plugin-generated-jar-files-tp23061582p27917297.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]