/** * Create a new enunciate configuration. The module list will be constructed * using Sun's discovery mechanism and the specified classloader. * * @param loader the classloader to use. */ public EnunciateConfiguration(ClassLoader loader) { this.modules = new TreeSet<DeploymentModule>(new DeploymentModuleComparator()); Iterator discoveredModules = discoverModules(loader); while (discoveredModules.hasNext()) { DeploymentModule discoveredModule = (DeploymentModule) discoveredModules.next(); this.modules.add(discoveredModule); } this.modules.add(new BasicAppModule()); }
@Override protected void doPackage() throws EnunciateException, IOException { if (getWebAppConfig() == null || getWebAppConfig().isDoPackage()) { File buildDir = getBuildDir(); File warFile = getWarFile(); Enunciate enunciate = getEnunciate(); if (!enunciate.isUpToDate(buildDir, warFile)) { if (!warFile.getParentFile().exists()) { warFile.getParentFile().mkdirs(); } debug("Creating %s", warFile.getAbsolutePath()); enunciate.zip(warFile, buildDir); } else { info("Skipping war file creation as everything appears up-to-date..."); } enunciate.addArtifact(new FileArtifact(getName(), "war.file", warFile)); } else { debug("Packaging has been disabled. No packaging will be performed."); } }
/** * Copy the post base. */ protected void copyPostBase() throws IOException { Enunciate enunciate = getEnunciate(); File buildDir = getBuildDir(); //extract a post base if specified. WebAppConfig webAppConfig = getWebAppConfig(); if ((webAppConfig != null) && (webAppConfig.getPostBase() != null)) { File postBase = enunciate.resolvePath(webAppConfig.getPostBase()); if (postBase.isDirectory()) { debug("Copying postBase directory %s to %s...", postBase, buildDir); enunciate.copyDir(postBase, buildDir); } else { debug("Extracting postBase zip file %s to %s...", postBase, buildDir); enunciate.extractBase(new FileInputStream(postBase), buildDir); } } }
@Override public File getBuildDir() { File buildDir = null; WebAppConfig webAppConfig = getWebAppConfig(); if (webAppConfig != null && webAppConfig.getDir() != null) { buildDir = getEnunciate().resolvePath(webAppConfig.getDir()); buildDir.mkdirs(); } return buildDir == null ? super.getBuildDir() : buildDir; } }
@Override protected void doBuild() throws IOException, EnunciateException { Enunciate enunciate = getEnunciate(); File buildDir = getBuildDir(); copyPreBase(); debug("Building the expanded WAR in %s", buildDir); if (getWebAppConfig() != null && !getWebAppConfig().getGlobalServletFilters().isEmpty()) { Set<String> allServletNames = new TreeSet<String>(); for (WebAppFragment fragment : enunciate.getWebAppFragments()) { for (FilterComponent filter : getWebAppConfig().getGlobalServletFilters()) { filter.setServletNames(allServletNames); filter.setDispatchers(new TreeSet<String>(Arrays.asList("FORWARD", "REQUEST"))); fragment.setFilters(getWebAppConfig().getGlobalServletFilters()); enunciate.addWebAppFragment(fragment); if (getWebAppConfig() == null || getWebAppConfig().isDoCompile()) { enunciate.copyDir(getCompileDir(), webinfClasses); if (getWebAppConfig() == null || getWebAppConfig().isDoLibCopy()) { doLibCopy(); debug("Lib copy has been disabled. No libs will be copied, nor any manifest written."); generateWebXml();
Enunciate enunciate = getEnunciate(); File buildDir = getBuildDir(); File webinf = new File(buildDir, "WEB-INF"); webinf.mkdirs(); File destWebXML = new File(webinf, "web.xml"); File configDir = getGenerateDir(); File webXML = new File(configDir, "web.xml"); EnunciateFreemarkerModel model = getModel(); model.setFileOutputDirectory(configDir); try { List<WebAppResource> resourceEnvRefs = Collections.<WebAppResource>emptyList(); List<WebAppResource> resourceRefs = Collections.<WebAppResource>emptyList(); WebAppConfig webAppConfig = getWebAppConfig(); if (webAppConfig != null) { envEntries = webAppConfig.getEnvEntries(); processTemplate(getWebXmlTemplateURL(), model); WebAppConfig webAppConfig = getWebAppConfig(); if ((webAppConfig != null) && (webAppConfig.getMergeWebXMLURL() != null || webAppConfig.getMergeWebXML() != null)) { URL webXmlToMerge = webAppConfig.getMergeWebXMLURL(); Document source1Doc = loadMergeXml(webXmlToMerge.openStream()); NodeModel.simplify(source1Doc); Document source2Doc = loadMergeXml(new FileInputStream(webXML)); NodeModel.simplify(source2Doc);
@Override protected void doCompile() throws EnunciateException, IOException { Enunciate enunciate = getEnunciate(); if (getWebAppConfig() != null && !getWebAppConfig().isDoCompile()) { debug("Compilation has been disabled. No server-side classes will be compiled, nor will any resources be copied."); return; final File compileDir = getCompileDir(); if (!enunciate.isUpToDateWithSources(compileDir)) { enunciate.compileSources(compileDir); if (getWebAppConfig() != null && !getWebAppConfig().getCopyResources().isEmpty()) { AntPatternMatcher matcher = new AntPatternMatcher(); for (CopyResources copyResource : getWebAppConfig().getCopyResources()) { String pattern = copyResource.getPattern(); if (pattern == null) { warn("'%s' is not a valid pattern. Resources NOT copied!", pattern); continue; info("Skipping compilation as everything appears up-to-date...");
Enunciate enunciate = getEnunciate(); File buildDir = getBuildDir(); File webinf = new File(buildDir, "WEB-INF"); File webinfClasses = new File(webinf, "classes"); List<File> explicitIncludes = new ArrayList<File>(); List<String> includePatterns = new ArrayList<String>(); WebAppConfig webAppConfig = getWebAppConfig(); if (webAppConfig != null) { for (IncludeExcludeLibs el : webAppConfig.getIncludeLibs()) { warn("Pattern '%s' is not a valid pattern, so it will not be applied.", pattern); debug("No include patterns have been specified. Using the implicit '%s' pattern.", starPattern); includePatterns.add(starPattern); debug("Using the Enunciate classpath as the initial list of libraries to be passed through the include/exclude filter."); debug("Library '%s' passed the include filter. It matches pattern '%s'.", libFile.getAbsolutePath(), includePattern); includedLibs.add(libFile); break; debug("Library '%s' did NOT match include pattern '%s'.", includePattern); while (toBeIncludedIt.hasNext()) { File toBeIncluded = toBeIncludedIt.next(); if (excludeDefaults && knownExclude(toBeIncluded)) { toBeIncludedIt.remove();
/** * The war file to create. * * @return The war file to create. */ public File getWarFile() { WebAppConfig config = getWebAppConfig(); if (config != null && config.getWar() != null) { return getEnunciate().resolvePath(config.getWar()); } else { String filename = "enunciate.war"; if (getEnunciate().getConfig().getLabel() != null) { filename = getEnunciate().getConfig().getLabel() + ".war"; } return new File(getPackageDir(), filename); } }
public WebAppConfig getWebAppConfig() { return (getEnunciate() != null && getEnunciate().getConfig() != null) ? getEnunciate().getConfig().getWebAppConfig() : null; }
debug("%s is a known include because it contains the entry META-INF/enunciate/preserve-in-war.", file); debug("%s is a known exclude because it appears to be tools.jar.", file); debug("%s is a known exclude because it appears to be apt-jelly.", file); debug("%s is a known exclude because it appears to be the apt-jelly-freemarker libs.", file); debug("%s is a known exclude because it appears to be the freemarker libs.", file); debug("%s is a known exclude because it appears to be the enunciate core jar.", file); debug("%s is a known exclude because it appears to be the servlet api.", file); debug("%s is a known exclude because it appears to be the enunciated xfire client tools jar.", file); debug("%s is a known exclude because it appears to be dt.jar.", file); debug("%s is a known exclude because it appears to be htmlconverter.jar.", file); return true; debug("%s is a known exclude because it appears to be jconsole.jar.", file); return true; debug("%s is a known exclude because it appears to be sa-jdi.jar.", file); return true; debug("%s is a known exclude because it appears to be charsets.jar.", file); return true;
/** * Copy the pre base. */ protected void copyPreBase() throws IOException { Enunciate enunciate = getEnunciate(); File buildDir = getBuildDir(); WebAppConfig webAppConfig = getWebAppConfig(); if ((webAppConfig != null) && (webAppConfig.getPreBase() != null)) { File preBase = enunciate.resolvePath(webAppConfig.getPreBase()); if (preBase.isDirectory()) { debug("Copying preBase directory %s to %s...", preBase, buildDir); enunciate.copyDir(preBase, buildDir); } else { debug("Extracting preBase zip file %s to %s...", preBase, buildDir); enunciate.extractBase(new FileInputStream(preBase), buildDir); } } }
modules.add(new BasicAppModule()); config = new EnunciateConfiguration(modules);