@Override public boolean equals(final Object other) { return other == this || other instanceof GAV && compareTo((GAV) other) == 0; }
/** * Constructor for a dependency with the given attributes. * * @param gav the coordinates to use (required) * @param type the dependency type (required) * @param scope the dependency scope (required) * @since 1.2.1 */ public Dependency(final GAV gav, final DependencyType type, final DependencyScope scope) { this(gav.getGroupId(), gav.getArtifactId(), gav.getVersion(), type, scope); }
/** * @return a simple description, as would be used for console output */ public String getSimpleDescription() { return gav.toString(); }
/** * Returns an instance based on the given concatenated Maven coordinates. * * @param coordinates the groupId, artifactId, and version, separated by * {@link MavenUtils#COORDINATE_SEPARATOR} * @return a non-blank instance * @throws IllegalArgumentException if the string is not formatted as * explained above, or if any of the elements are themselves * invalid. */ public static GAV getInstance(final String coordinates) { final String[] coordinateArray = ArrayUtils.nullToEmpty(StringUtils.split(coordinates, MavenUtils.COORDINATE_SEPARATOR)); Validate.isTrue(coordinateArray.length == 3, "Expected three coordinates, but found " + coordinateArray.length + ": " + Arrays.toString(coordinateArray) + "; did you use the '" + MavenUtils.COORDINATE_SEPARATOR + "' separator?"); return new GAV(coordinateArray[0], coordinateArray[1], coordinateArray[2]); }
/** * Returns the ID of the organisation or group that owns this module or * project * * @return a non-blank ID */ public String getGroupId() { return gav.getGroupId(); }
/** * Returns the version number of this module or project * * @return a non-blank version number */ public String getVersion() { return gav.getVersion(); }
/** * Returns the ID of the artifact created by this module or project * * @return a non-blank ID */ public String getArtifactId() { return gav.getArtifactId(); }
@Override public int hashCode() { final int prime = 31; final int result = prime * 1 + gav.hashCode(); return prime * result + (configuration == null ? 0 : configuration.hashCode()); }
/** * Indicates whether a plugin with the given coordinates is registered * * @param coordinates the coordinates to match upon; can be * <code>null</code> * @return false if <code>null</code> coordinates are given */ public boolean isPluginRegistered(final GAV gav) { for (final Plugin existingPlugin : buildPlugins) { if (existingPlugin.getGAV().equals(gav)) { return true; } } return false; }
/** * Constructor that allows all fields to be set. * * @param groupId the group ID (required) * @param artifactId the artifact ID (required) * @param version the version (required) * @param configuration the configuration for this plugin (optional) * @param dependencies the dependencies for this plugin (can be * <code>null</code>) * @param executions the executions for this plugin (can be * <code>null</code>) */ public Plugin(final String groupId, final String artifactId, final String version, final Configuration configuration, final Collection<? extends Dependency> dependencies, final Collection<? extends Execution> executions) { Validate.notNull(groupId, "Group ID required"); Validate.notNull(artifactId, "Artifact ID required"); //Validate.notNull(version, "Version required"); if (version == null || version == "") { gav = new GAV(groupId, artifactId, "-"); } else { gav = new GAV(groupId, artifactId, version); } this.configuration = configuration; // Defensively copy the given nullable collections CollectionUtils.populate(this.dependencies, dependencies); CollectionUtils.populate(this.executions, executions); }
/** * Returns this plugin's groupId. * * @return */ public String getGroupId() { return gav.getGroupId(); }
public String getVersion() { return gav.getVersion(); }
public String getArtifactId() { return gav.getArtifactId(); }
public int compareTo(final GAV other) { Validate.notNull(other, "Cannot compare %s to null", this); int result = groupId.compareTo(other.getGroupId()); if (result == 0) { result = artifactId.compareTo(other.getArtifactId()); } if (result == 0) { result = version.compareTo(other.getVersion()); } return result; }
private void createModule(final String moduleName, final PackagingProvider selectedPackagingProvider, final String artifactId, final String folder) { Validate.isTrue(isCreateModuleAvailable(), "Cannot create modules at this time"); if (getProjectOperations().getPomFromModuleName(moduleName) != null) { throw new IllegalArgumentException(String.format("Module %s already exists", moduleName)); } // Get parent pom Pom parentPom = getProjectOperations().getPomFromModuleName(""); setModule(parentPom); // Validate parent has POM packaging if (!parentPom.getPackaging().equals("pom")) { throw new IllegalArgumentException("ERROR: Parent module packaging is not POM"); } final PackagingProvider packagingProvider = getPackagingProvider(selectedPackagingProvider); final String pathToNewPom = packagingProvider.createArtifacts( getProjectOperations().getTopLevelPackage(parentPom.getModuleName()), artifactId, "", new GAV(parentPom.getGroupId(), parentPom.getArtifactId(), parentPom.getVersion()), moduleName, this); updateParentModulePom(moduleName); setModule(pomManagementService.getPomFromPath(pathToNewPom)); if (folder == null) { createFolder(getProjectOperations().getTopLevelPackage(moduleName), null); } else { createFolder(getProjectOperations().getTopLevelPackage(parentPom.getModuleName()), folder); } }
} else { pom = XmlUtils.readXml(FileUtils.getInputStream(getClass(), pomModuleTemplate)); groupId = parentPom.getGroupId();
public int compareTo(final Plugin o) { if (o == null) { throw new NullPointerException(); } int result = gav.compareTo(o.getGAV()); if (result == 0 && configuration != null && o.configuration != null) { result = configuration.compareTo(o.configuration); } return result; }
parentPom.getGroupId()); DomUtils.createChildIfNotExists("artifactId", parentPomElement, pom).setTextContent( parentPom.getArtifactId()); DomUtils.createChildIfNotExists(VERSION_ELEMENT, parentPomElement, pom).setTextContent( parentPom.getVersion()); if (projectGroupId.equals(parentPom.getGroupId())) {