@SuppressWarnings("unchecked") protected Configuration createConfiguration() { // retrievethe Build object Build build = getExporterMojo().getProject().getBuild(); Log log = getExporterMojo().getLog(); // now create an empty arraylist that is going to hold our entities List<String> entities = new ArrayList<String>(); try { if (getExporterMojo().getComponentProperty("scan-classes", false)) { File outputDirectory = new File(build.getOutputDirectory()); entities.addAll(new PersistenceClassScanner(log).scanDir(outputDirectory)); File testOutputDirectory = new File(build.getTestOutputDirectory()); entities.addAll(new PersistenceClassScanner(log).scanDir(testOutputDirectory)); } if (getExporterMojo().getComponentProperty("scan-jars", false)) { for (File jarFile : getJarFiles()) { entities.addAll(new PersistenceClassScanner(log).scanJar(jarFile)); } } } catch (Exception e) { getExporterMojo().getLog().error(e.getMessage(), e); return null; } // now create the configuration object Configuration configuration = new Configuration(); addNamedAnnotatedClasses(configuration, entities); return configuration; }
public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("Building JavaFX JAR for application"); Build build = project.getBuild(); CreateJarParams createJarParams = new CreateJarParams(); createJarParams.setOutdir(jfxAppOutputDir); createJarParams.setOutfile(jfxMainAppJarName); createJarParams.setApplicationClass(mainClass); createJarParams.setCss2bin(css2bin); createJarParams.addResource(new File(build.getOutputDirectory()), ""); createJarParams.setPreloader(preLoader); StringBuilder classpath = new StringBuilder(); File libDir = new File(jfxAppOutputDir, "lib"); if (!libDir.exists() && !libDir.mkdirs()) { throw new MojoExecutionException("Unable to create app lib dir: " + libDir); } try { for (Object object : project.getRuntimeClasspathElements()) { String path = (String) object; File file = new File(path); if (file.isFile()) { getLog().debug("Including classpath element: " + path); File dest = new File(libDir, file.getName()); if (!dest.exists()) { Files.copy(file.toPath(), dest.toPath()); } classpath.append("lib/").append(file.getName()).append(" "); } } } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException( "Error resolving application classpath to use for application", e); } catch (IOException e) { throw new MojoExecutionException("Error copying dependency for application", e); } createJarParams.setClasspath(classpath.toString()); try { getPackagerLib().packageAsJar(createJarParams); } catch (PackagerException e) { throw new MojoExecutionException("Unable to build JFX JAR for application", e); } }