@Override public void setup() { if (!fileManager.exists( projectOperations .getPathResolver() .getFocusedIdentifier(SRC_MAIN_WEBAPP, "WEB-INF/web.xml"))) { webMvcOperations.installAllWebMvcArtifacts(); } final Element configuration = XmlUtils.getConfiguration(getClass()); for (Element propertyElement : XmlUtils.findElements("/configuration/batch/properties/*", configuration)) { projectOperations.addProperty( projectOperations.getFocusedModuleName(), new Property(propertyElement)); } final List<Dependency> dependencies = new ArrayList<Dependency>(); for (final Element dependencyElement : XmlUtils.findElements("/configuration/batch/dependencies/*", configuration)) { dependencies.add(new Dependency(dependencyElement)); } projectOperations.removeDependencies(projectOperations.getFocusedModuleName(), dependencies); metadataService.evict( ProjectMetadata.getProjectIdentifier(projectOperations.getFocusedModuleName())); projectOperations.addDependencies(projectOperations.getFocusedModuleName(), dependencies); final String webConfigFile = pathResolver.getFocusedIdentifier(Path.SRC_MAIN_WEBAPP, WEBMVC_CONFIG_XML); Validate.isTrue(fileManager.exists(webConfigFile), "Aborting: Unable to find " + webConfigFile); InputStream webMvcConfigInputStream = null; try { webMvcConfigInputStream = fileManager.getInputStream(webConfigFile); Validate.notNull( webMvcConfigInputStream, "Aborting: Unable to acquire webmvc-config.xml file"); final Document webMvcConfig = XmlUtils.readXml(webMvcConfigInputStream); final Element root = webMvcConfig.getDocumentElement(); if (XmlUtils.findFirstElement("/beans/bean[@class='" + REST_MVC_CONFIG + "']", root) == null) { final Element config = webMvcConfig.createElement("bean"); config.setAttribute("class", REST_MVC_CONFIG); root.appendChild(config); fileManager.createOrUpdateTextFileIfRequired( webConfigFile, XmlUtils.nodeToString(webMvcConfig), true); } } finally { IOUtils.closeQuietly(webMvcConfigInputStream); } }
@Override public void dependency(final AndroidProjectDependency dependency) { final String moduleName = projectOperations.getFocusedModuleName(); final Element configuration = XmlUtils.getConfiguration(getClass()); for (final Element propertyElement : XmlUtils.findElements( "/configuration/" + dependency.getTag() + "/properties/property", configuration)) { final Property property = new Property(propertyElement); projectOperations.addProperty(moduleName, property); } final List<AndroidDependency> dependencies = new ArrayList<AndroidDependency>(); for (final Element dependencyElement : XmlUtils.findElements( "/configuration/" + dependency.getTag() + "/dependencies/dependency", configuration)) { dependencies.add(new AndroidDependency(dependencyElement)); } projectOperations.removeDependencies(moduleName, dependencies); metadataService.evict(ProjectMetadata.getProjectIdentifier(moduleName)); androidTypeService.addDependencies(moduleName, dependencies); }
protected ProjectMetadata projectMetadata() { return (ProjectMetadata) _metadataService.get(ProjectMetadata.getProjectIdentifier()); }