本文整理汇总了Java中org.apache.maven.artifact.ArtifactUtils.isSnapshot方法的典型用法代码示例。如果您正苦于以下问题:Java ArtifactUtils.isSnapshot方法的具体用法?Java ArtifactUtils.isSnapshot怎么用?Java ArtifactUtils.isSnapshot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.ArtifactUtils
的用法示例。
在下文中一共展示了ArtifactUtils.isSnapshot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
/**
* Uses the {@link DefaultVersionsHelper} to find all available versions that match all the associations with this
* property.
*
* @param includeSnapshots Whether to include snapshot versions in our search.
* @return The (possibly empty) array of versions.
*/
public synchronized ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<>( getVersionComparator() );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return asArtifactVersionArray( result );
}
示例2: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
public ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<>( versionComparator );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return result.toArray( new ArtifactVersion[result.size()] );
}
示例3: getNewVersion
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
private String getNewVersion( ExternalVersionStrategy strategy, MavenProject mavenProject )
throws ExternalVersionException
{
// snapshot detection against the old version.
boolean isSnapshot = ArtifactUtils.isSnapshot( mavenProject.getVersion() );
// lookup the new version
String newVersion = strategy.getVersion( mavenProject );
if ( newVersion != null )
{
newVersion = newVersion.trim();
}
boolean isNewSnapshot = ArtifactUtils.isSnapshot( newVersion );
// make sure we still have a SNAPSHOT if we had one previously.
if ( isSnapshot && !isNewSnapshot )
{
newVersion = newVersion + "-SNAPSHOT";
}
return newVersion;
}
示例4: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
/**
* Uses the {@link DefaultVersionsHelper} to find all available versions that match all
* the associations with this property.
*
* @param includeSnapshots Whether to include snapshot versions in our search.
* @return The (possibly empty) array of versions.
*/
public synchronized ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<ArtifactVersion>( getVersionComparator() );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return asArtifactVersionArray( result );
}
示例5: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
public ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<ArtifactVersion>( versionComparator );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return result.toArray( new ArtifactVersion[result.size()] );
}
示例6: getHtmlDisplayName
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
@Override
public String getHtmlDisplayName() {
StringBuilder n = new StringBuilder("<html>");
n.append(getDisplayName());
if (ArtifactUtils.isSnapshot(data.art.getVersion()) && data.art.getVersion().indexOf("SNAPSHOT") < 0) { //NOI18N
n.append(" <b>[").append(data.art.getVersion()).append("]</b>");
}
if (!data.art.getArtifactHandler().isAddedToClasspath() && !Artifact.SCOPE_COMPILE.equals(data.art.getScope())) {
n.append(" <i>[").append(data.art.getScope()).append("]</i>");
}
n.append("</html>");
return n.toString();
}
示例7: getNewestVersion
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
public final ArtifactVersion getNewestVersion( VersionRange versionRange, ArtifactVersion lowerBound,
ArtifactVersion upperBound, boolean includeSnapshots,
boolean includeLower, boolean includeUpper )
{
ArtifactVersion latest = null;
final VersionComparator versionComparator = getVersionComparator();
Iterator i = Arrays.asList( getVersions( includeSnapshots ) ).iterator();
while ( i.hasNext() )
{
ArtifactVersion candidate = (ArtifactVersion) i.next();
if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) )
{
continue;
}
int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate );
int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate );
if ( lower > 0 || upper < 0 )
{
continue;
}
if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) )
{
continue;
}
if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
if ( latest == null )
{
latest = candidate;
}
else if ( versionComparator.compare( latest, candidate ) < 0 )
{
latest = candidate;
}
}
return latest;
}
示例8: getOldestVersion
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
public final ArtifactVersion getOldestVersion( VersionRange versionRange, ArtifactVersion lowerBound,
ArtifactVersion upperBound, boolean includeSnapshots,
boolean includeLower, boolean includeUpper )
{
ArtifactVersion oldest = null;
final VersionComparator versionComparator = getVersionComparator();
Iterator i = Arrays.asList( getVersions( includeSnapshots ) ).iterator();
while ( i.hasNext() )
{
ArtifactVersion candidate = (ArtifactVersion) i.next();
if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) )
{
continue;
}
int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate );
int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate );
if ( lower > 0 || upper < 0 )
{
continue;
}
if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) )
{
continue;
}
if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
if ( oldest == null )
{
oldest = candidate;
}
else if ( versionComparator.compare( oldest, candidate ) > 0 )
{
oldest = candidate;
}
}
return oldest;
}
示例9: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
public final ArtifactVersion[] getVersions( VersionRange versionRange, ArtifactVersion lowerBound,
ArtifactVersion upperBound, boolean includeSnapshots,
boolean includeLower, boolean includeUpper )
{
final VersionComparator versionComparator = getVersionComparator();
Set<ArtifactVersion> result = new TreeSet<>( versionComparator );
for ( ArtifactVersion candidate : Arrays.asList( getVersions( includeSnapshots ) ) )
{
if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) )
{
continue;
}
int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate );
int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate );
if ( lower > 0 || upper < 0 )
{
continue;
}
if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) )
{
continue;
}
if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
return result.toArray( new ArtifactVersion[result.size()] );
}
示例10: execute
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
@Override
protected void execute(final GitBranchType type, final String gitBranch, final String branchPattern) throws MojoExecutionException, MojoFailureException {
if (GitBranchType.VERSIONED_TYPES.contains(type)) {
getLog().debug("Versioned Branch Type: " + type + " with branchPattern: " + branchPattern + " Checking against current branch: " + gitBranch);
Matcher gitMatcher = Pattern.compile(branchPattern).matcher(gitBranch);
// We're in a release branch, we expect a non-SNAPSHOT version in the POM.
if (gitMatcher.matches()) {
if (ArtifactUtils.isSnapshot(project.getVersion())) {
throw new MojoFailureException("The current git branch: [" + gitBranch + "] is defined as a release branch. The maven project version: [" + project.getVersion() + "] is currently a snapshot version.");
}
// Non-master version branches require a pom version match of some kind to the branch subgroups.
if (gitMatcher.groupCount() > 0) {
// HOTFIX and RELEASE branches require an exact match to the last subgroup.
if ((GitBranchType.RELEASE.equals(type) || GitBranchType.HOTFIX.equals(type)) && !gitMatcher.group(gitMatcher.groupCount()).trim().equals(project.getVersion().trim())) {
throw new MojoFailureException("The current git branch: [" + gitBranch + "] expected the maven project version to be: [" + gitMatcher.group(gitMatcher.groupCount()).trim() + "], but the maven project version is: [" + project.getVersion() + "]");
}
// SUPPORT branches require a 'starts with' match of the maven project version to the subgroup.
// ex: /origin/support/3.1 must have a maven version that starts with "3.1", ala: "3.1.2"
if (GitBranchType.SUPPORT.equals(type) && !project.getVersion().startsWith(gitMatcher.group(gitMatcher.groupCount()).trim())) {
throw new MojoFailureException("The current git branch: [" + gitBranch + "] expected the maven project version to start with: [" + gitMatcher.group(gitMatcher.groupCount()).trim() + "], but the maven project version is: [" + project.getVersion() + "]");
}
}
}
} else if (GitBranchType.DEVELOPMENT.equals(type) && !ArtifactUtils.isSnapshot(project.getVersion())) {
throw new MojoFailureException("The current git branch: [" + gitBranch + "] is detected as the gitflow development branch, and expects a maven project version ending with -SNAPSHOT. The maven project version found was: [" + project.getVersion() + "]");
}
}
示例11: getNewestVersion
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
public final ArtifactVersion getNewestVersion( VersionRange versionRange, ArtifactVersion lowerBound,
ArtifactVersion upperBound, boolean includeSnapshots,
boolean includeLower, boolean includeUpper )
{
ArtifactVersion latest = null;
final VersionComparator versionComparator = getVersionComparator();
Iterator i = Arrays.asList( getVersions( includeSnapshots ) ).iterator();
while ( i.hasNext() )
{
ArtifactVersion candidate = (ArtifactVersion) i.next();
if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) )
{
continue;
}
int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate );
int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate );
if ( lower > 0 || upper < 0 )
{
continue;
}
if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) )
{
continue;
}
if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
if ( latest == null )
{
latest = candidate;
}
else if ( versionComparator.compare( latest, candidate ) < 0 )
{
latest = candidate;
}
}
return latest;
}
示例12: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
public final ArtifactVersion[] getVersions( VersionRange versionRange, ArtifactVersion lowerBound,
ArtifactVersion upperBound, boolean includeSnapshots,
boolean includeLower, boolean includeUpper )
{
Set<ArtifactVersion> result;
final VersionComparator versionComparator = getVersionComparator();
result = new TreeSet<ArtifactVersion>( versionComparator );
for ( ArtifactVersion candidate : Arrays.asList( getVersions( includeSnapshots ) ) )
{
if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) )
{
continue;
}
int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate );
int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate );
if ( lower > 0 || upper < 0 )
{
continue;
}
if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) )
{
continue;
}
if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
return result.toArray( new ArtifactVersion[result.size()] );
}
示例13: getArtifactVersion
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
private ArtifactVersion getArtifactVersion() {
if (ArtifactUtils.isSnapshot(product_version)) {
product_version = StringUtils.substring(product_version, 0, product_version.length()
- Artifact.SNAPSHOT_VERSION.length() - 1);
}
return new DefaultArtifactVersion(product_version);
}
示例14: checkSnapshotDependencies
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
protected void checkSnapshotDependencies() throws MojoFailureException {
getLog().info("Checking for SNAPSHOT versions in dependencies.");
List<String> snapshots = new ArrayList<String>();
List<String> builtArtifacts = new ArrayList<String>();
List<MavenProject> projects = mavenSession.getProjects();
for (MavenProject project : projects) {
builtArtifacts.add(project.getGroupId() + ":"
+ project.getArtifactId() + ":" + project.getVersion());
List<Dependency> dependencies = project.getDependencies();
for (Dependency d : dependencies) {
String id = d.getGroupId() + ":" + d.getArtifactId() + ":"
+ d.getVersion();
if (!builtArtifacts.contains(id)
&& ArtifactUtils.isSnapshot(d.getVersion())) {
snapshots.add(project + " -> " + d);
}
}
}
if (!snapshots.isEmpty()) {
for (String s : snapshots) {
getLog().warn(s);
}
throw new MojoFailureException(
"There is some SNAPSHOT dependencies in the project, see warnings above. Change them or ignore with `allowSnapshots` property.");
}
}
示例15: execute
import org.apache.maven.artifact.ArtifactUtils; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
public void execute()
{
org.apache.maven.artifact.Artifact artifact =
artifactFactory.createArtifact( getProject().getGroupId(), getProject().getArtifactId(), "", "", "" );
try
{
ArtifactVersion releasedVersion = null;
List<ArtifactVersion> versions =
artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository,
remoteArtifactRepositories );
for ( ArtifactVersion version : versions )
{
if ( !ArtifactUtils.isSnapshot( version.toString() )
&& ( releasedVersion == null || version.compareTo( releasedVersion ) > 0 ) )
{
releasedVersion = version;
}
}
if ( releasedVersion != null )
{
// Use ArtifactVersion.toString(), the major, minor and incrementalVersion return all an int.
String releasedVersionValue = releasedVersion.toString();
// This would not always reflect the expected version.
int dashIndex = releasedVersionValue.indexOf( '-' );
if ( dashIndex >= 0 )
{
releasedVersionValue = releasedVersionValue.substring( 0, dashIndex );
}
defineVersionProperty( "version", releasedVersionValue );
defineVersionProperty( "majorVersion", releasedVersion.getMajorVersion() );
defineVersionProperty( "minorVersion", releasedVersion.getMinorVersion() );
defineVersionProperty( "incrementalVersion", releasedVersion.getIncrementalVersion() );
defineVersionProperty( "buildNumber", releasedVersion.getBuildNumber() );
defineVersionProperty( "qualifier", releasedVersion.getQualifier() );
}
}
catch ( ArtifactMetadataRetrievalException e )
{
if ( getLog().isWarnEnabled() )
{
getLog().warn( "Failed to retrieve artifacts metadata, cannot resolve the released version" );
}
}
}