localVersion.setMajor(defaultArtifactVersion.getMajorVersion()); localVersion.setMinor(defaultArtifactVersion.getMinorVersion()); localVersion.setRevision(defaultArtifactVersion.getIncrementalVersion());
static boolean isCompatibleVersion( String myName, String myVersion, String otherName, @Nullable String otherVersion) { String effectiveOtherVersion = firstNonNull(otherVersion, UNKNOWN_VERSION); if (effectiveOtherVersion.equals(INCOMPATIBLE_VERSION) || myVersion.equals(INCOMPATIBLE_VERSION)) { return false; } if (effectiveOtherVersion.equals(UNKNOWN_VERSION) || myVersion.equals(UNKNOWN_VERSION)) { // Either version is unknown, assume compatible. return true; } DefaultArtifactVersion myArtifactVersion = parseVersion(myVersion, myName); DefaultArtifactVersion otherArtifactVersion = parseVersion(effectiveOtherVersion, otherName); return myArtifactVersion.getMajorVersion() == otherArtifactVersion.getMajorVersion() && myArtifactVersion.getMinorVersion() == otherArtifactVersion.getMinorVersion(); }
/** * Check the current Maven version to see if it's Maven 3.0 or newer. */ private static boolean isMaven3OrMore() { return new DefaultArtifactVersion( getMavenVersion() ).getMajorVersion() >= 3; }
/** Utility to parse versions, with error handling. */ private static DefaultArtifactVersion parseVersion(String version, String name) { DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(version); if (artifactVersion.getMajorVersion() == 0 && artifactVersion.getMinorVersion() == 0) { throw new BatfishException(String.format("Illegal version '%s' for %s", version, name)); } return artifactVersion; }
private Artifact getNewArtifact( Model companyModel ) { String v = companyModel.getVersion(); String newVersion; if ( v != null ) { DefaultArtifactVersion version = new DefaultArtifactVersion( v ); newVersion = String.valueOf( version.getMajorVersion() + 1 ); } else { newVersion = "1"; } companyModel.setVersion( newVersion ); return artifactFactory.createProjectArtifact( companyModel.getGroupId(), companyModel.getArtifactId(), newVersion ); }