@Override public boolean isDisabled() { return getWebAppConfig() != null && getWebAppConfig().isDisabled(); }
@Override public void init(Enunciate enunciate) throws EnunciateException { super.init(enunciate); if (!isDisabled()) { if (getWebAppConfig() != null && !getWebAppConfig().getGlobalServletFilters().isEmpty()) { for (WebAppComponent globalServletFilter : getWebAppConfig().getGlobalServletFilters()) { if (globalServletFilter.getName() == null) { throw new EnunciateException("A global servlet filter (as specified in the enunciate config) requires a name."); } if (globalServletFilter.getClassname() == null) { throw new EnunciateException("A global servlet filter (as specified in the enunciate config) requires a classname."); } } } } }
@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 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."); } }
List<File> explicitIncludes = new ArrayList<File>(); List<String> includePatterns = new ArrayList<String>(); WebAppConfig webAppConfig = getWebAppConfig(); if (webAppConfig != null) { for (IncludeExcludeLibs el : webAppConfig.getIncludeLibs()) {
@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; 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) {
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()) { if (getWebAppConfig() == null || getWebAppConfig().isDoLibCopy()) { doLibCopy();
/** * 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); } } }
/** * 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); } } }
List<WebAppResource> resourceEnvRefs = Collections.<WebAppResource>emptyList(); List<WebAppResource> resourceRefs = Collections.<WebAppResource>emptyList(); WebAppConfig webAppConfig = getWebAppConfig(); if (webAppConfig != null) { envEntries = webAppConfig.getEnvEntries(); WebAppConfig webAppConfig = getWebAppConfig(); if ((webAppConfig != null) && (webAppConfig.getMergeWebXMLURL() != null || webAppConfig.getMergeWebXML() != null)) { URL webXmlToMerge = webAppConfig.getMergeWebXMLURL();
/** * 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); } }