/** * Sets build configuration, see {@link Activation} * * @param build new build * @return this profile instance */ public Profile setBuild(Build build) { this.build = build; if (!isNew()) { if (build == null) { element.removeChild("build"); } else if (element.hasSingleChild("build")) { element.removeChild("build"); element.appendChild(build.asXMLElement()); } else { element.appendChild(build.asXMLElement()); } } return this; }
/** * Sets build settings for project. * * <p>If {@code build} is {@code null} then it will be removed from model and xml as well. * * @param build new build * @return this model instance */ public Model setBuild(Build build) { this.build = build; if (build == null) { root.removeChild("build"); } else if (root.hasSingleChild("build")) { // replace build build.buildElement = root.getSingleChild("build").replaceWith(build.asXMLElement()); } else { // add build root.appendChild(this.build.asXMLElement()); build.buildElement = root.getSingleChild("build"); } return this; }
/** Returns profile element as XML element. */ public NewElement asXMLElement() { final NewElement profile = createElement("profile"); if (!isNullOrEmpty(id)) { profile.appendChild(createElement("id", id)); } if (modules != null && !modules.isEmpty()) { profile.appendChild(newModulesXMLElement(modules)); } if (activation != null) { profile.appendChild(activation.asXMLElement()); } if (build != null) { profile.appendChild(build.asXMLElement()); } if (repositories != null && !repositories.isEmpty()) { profile.appendChild(newRepositoryElement(repositories)); } if (dependencies != null && !dependencies.get().isEmpty()) { profile.appendChild(newDependencyElement(dependencies.get())); } if (properties != null && !properties.isEmpty()) { profile.appendChild(newPropertiesElement(properties)); } if (dependencyManagement != null && !dependencyManagement.getDependencies().isEmpty()) { profile.appendChild(newDependencyManagementElement(dependencies.get())); } return profile; }