Refine search
public int compareTo( Artifact a ) int result = groupId.compareTo( a.getGroupId() ); if ( result == 0 ) result = artifactId.compareTo( a.getArtifactId() ); if ( result == 0 ) result = type.compareTo( a.getType() ); if ( result == 0 ) result = new DefaultArtifactVersion( version ).compareTo( new DefaultArtifactVersion( a.getVersion() ) );
@Override public String toString() { return version.toString(); } }
@Override public int compare(String o1, String o2) { //noinspection StringEquality if (o1 == o2) { return 0; } if (o1 == null) { return -1; } if (o2 == null) { return 1; } DefaultArtifactVersion version1 = new DefaultArtifactVersion(o1); DefaultArtifactVersion version2 = new DefaultArtifactVersion(o2); return version1.compareTo(version2); }
throws MojoExecutionException { File targetFolderFile = new File( targetFolder ); for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); ) { Artifact artifact = ( Artifact ) it.next(); File f = artifact.getFile(); throw new MojoExecutionException( "Cannot locate artifact file of " + artifact.getArtifactId() ); FileUtils.getFileNames( targetFolderFile, artifact.getArtifactId() + "-*.jar", null, false ); existing.get( 0 ).split( "(" + artifact.getArtifactId() + "-)" )[1].split( "(.jar)" )[0]; DefaultArtifactVersion existingVersion = new DefaultArtifactVersion( version ); DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion( artifact.getVersion() ); if ( existingVersion.compareTo( artifactVersion ) < 0 ) { // Remove existing version FileUtils.forceDelete( targetFolder + existing.get( 0 ) );
@Override public void run() { final Result<NBVersionInfo> result = RepositoryQueries.getVersionsResult(artifact.getGroupId(), artifact.getArtifactId(), RepositoryPreferences.getInstance().getRepositoryInfos()); final List<NBVersionInfo> infos = result.getResults(); final ArtifactVersion av = new DefaultArtifactVersion(artifact.getVersion()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dlm.removeAllElements(); for (NBVersionInfo ver : infos) { if (!av.equals(new DefaultArtifactVersion(ver.getVersion()))) { dlm.addElement(ver); } if (!artifact.getType().equals(ver.getType())) { renderType = true; } } if (result.isPartial()) { dlm.addElement(TXT_INCOMPLETE()); } } }); } });
private Artifact getTestNgArtifact() throws MojoExecutionException { Artifact artifact = getProjectArtifactMap().get( getTestNGArtifactName() ); Artifact projectArtifact = project.getArtifact(); String projectArtifactName = projectArtifact.getGroupId() + ":" + projectArtifact.getArtifactId(); if ( artifact != null ) { VersionRange range = createVersionRange(); if ( !range.containsVersion( new DefaultArtifactVersion( artifact.getVersion() ) ) ) { throw new MojoExecutionException( "TestNG support requires version 4.7 or above. You have declared version " + artifact.getVersion() ); } } else if ( projectArtifactName.equals( getTestNGArtifactName() ) ) { artifact = projectArtifact; } return artifact; }
File file = newArtifact.getFile(); + newArtifact.getGroupId() + ":" + newArtifact.getArtifactId() + ":" + newArtifact.getVersion() ); Artifact oldArtifact = compileArtifactMap.get( newArtifact.getDependencyConflictId() ); ArtifactVersion oldVersion = new DefaultArtifactVersion( oldArtifact.getVersion() ); ArtifactVersion newVersion = new DefaultArtifactVersion( newArtifact.getVersion() ); if ( newVersion.compareTo( oldVersion ) > 0 )
@Override public void execute() throws MojoExecutionException { boolean useNewPackagingType = extAsVersion != null && new DefaultArtifactVersion(extAsVersion).compareTo(EXT_AS_FIRST_SWC_ARTIFACT_VERSION) >= 0; if (!renameOnly && (hasExmlConfiguration() || "jangaroo".equals(getProject().getPackaging()))) { getLog().info("reading POM from " + getProject().getBasedir().getPath()); PomConverter pomConverter = new PomConverter(getProject().getBasedir()); File extAsJar = extAsArtifact.getFile();
ArtifactVersion selectedVersion = new DefaultArtifactVersion( version ); getLog().debug( "Selected version:" + selectedVersion.toString() ); if(getProject().getParent() != null){ if(artifact.getId().equals(getProject().getParentArtifact().getId()) && isProcessingParent()) getProject().getModel() ) )
@Override public void checkAmpsVersionInPom(String currentVersion, MavenProject project) if(skipCheck || (null == project.getFile() || !project.getFile().exists())) String prefKey = POM_UPDATE_PREF_PREFIX + "-" + currentVersion + "-" + DigestUtils.md5Hex(project.getArtifactId()); Preferences prefs = Preferences.userNodeForPackage(AmpsPluginVersionCheckerImpl.class); String alreadyRan = prefs.get(prefKey, null); DefaultArtifactVersion runningVersion = new DefaultArtifactVersion(currentVersion); Pair<Pair<DefaultArtifactVersion,PomVersionElement>,ProjectRewriter> versionInfo = getVersionAndRewriter(project); if(NO_VERSION_DEFINED.equalsIgnoreCase(versionInPom.toString()) || runningVersion.compareTo(versionInPom) > 0) if(pomElementType.equals(PomVersionElement.PLUGIN) && (NO_VERSION_DEFINED.equalsIgnoreCase(versionInPom.toString()) || runningVersion.compareTo(versionInPom) > 0))
/** * Ensure <code>artifactName</code> matches version <code>versionSpec</code>. */ private void checkVersion(String artifactName, String versionSpec, Artifact artifact) throws MojoExecutionException { VersionRange range; try { range = VersionRange.createFromVersionSpec(versionSpec); if (!range.containsVersion(new DefaultArtifactVersion(artifact.getVersion()))) { throw new MojoExecutionException( "JUnit4 plugin requires " + artifactName + " in version " + versionSpec + " among project dependencies, you declared: " + artifact.getVersion()); } } catch (InvalidVersionSpecificationException e) { throw new RuntimeException(e); } }
/** * @param artifactMetadataSource * @param project * @param localRepository * @return all available versions from most recent to oldest * @throws ArtifactMetadataRetrievalException */ protected final List<ArtifactVersion> getAvailableReleasedVersions(final ArtifactMetadataSource artifactMetadataSource, final MavenProject project, final ArtifactRepository localRepository) throws ArtifactMetadataRetrievalException { final List<ArtifactVersion> availableVersions = artifactMetadataSource.retrieveAvailableVersions(project.getArtifact(), localRepository, project.getRemoteArtifactRepositories()); availableVersions.remove(new DefaultArtifactVersion(project.getArtifact().getVersion())); for (final Iterator<ArtifactVersion> iterator = availableVersions.iterator(); iterator.hasNext();) { final ArtifactVersion artifactVersion = iterator.next(); if (Version.parse(artifactVersion.toString()).isSnapshot()) { iterator.remove(); } } //TODO proper sorting based on Version Collections.sort(availableVersions); Collections.reverse(availableVersions); return availableVersions; }
private ArtifactVersion extractArtifactVersion( boolean uniqueVersions, boolean usePremanagedVersion ) { if ( usePremanagedVersion && node.getPremanagedVersion() != null ) { return new DefaultArtifactVersion( node.getPremanagedVersion() ); } Artifact artifact = node.getArtifact(); String version = uniqueVersions ? artifact.getVersion() : artifact.getBaseVersion(); if ( version != null ) { return new DefaultArtifactVersion( version ); } try { return artifact.getSelectedVersion(); } catch ( OverConstrainedVersionException e ) { throw new RuntimeException( "Version ranges problem with " + node.getArtifact(), e ); } }
Artifact gwtUser = project.getArtifactMap().get( GWT_USER ); if (gwtUser != null) ArtifactVersion mojoGwtArtifactVersion = new DefaultArtifactVersion( mojoGwtVersion ); ArtifactVersion userGwtArtifactVersion = new DefaultArtifactVersion( gwtUser.getVersion() ); if ( userGwtArtifactVersion.compareTo( mojoGwtArtifactVersion ) < 0 ) getLog().warn( "Your project declares dependency on gwt-user " + gwtUser.getVersion() + ". This plugin is designed for at least gwt version " + mojoGwtVersion );
if ( testNgArtifact != null ) DefaultArtifactVersion defaultArtifactVersion = new DefaultArtifactVersion( testNgArtifact.getVersion() ); getProperties().setProperty( "testng.configurator", getConfiguratorName( defaultArtifactVersion, getConsoleLogger()
static boolean isWithinVersionSpec( @Nullable Artifact artifact, @Nonnull String versionSpec ) { if ( artifact == null ) { return false; } try { VersionRange range = createFromVersionSpec( versionSpec ); try { return range.containsVersion( artifact.getSelectedVersion() ); } catch ( NullPointerException e ) { return range.containsVersion( new DefaultArtifactVersion( artifact.getBaseVersion() ) ); } } catch ( InvalidVersionSpecificationException | OverConstrainedVersionException e ) { throw new RuntimeException( "Bug in plugin. Please report with stacktrace" ); } }
private ArtifactVersion determineArtifactVersion(Artifact artifact) throws MojoExecutionException { try { return artifact.getVersion() != null ? new DefaultArtifactVersion( artifact.getVersion() ) : artifact.getSelectedVersion(); } catch ( OverConstrainedVersionException e ) { throw new MojoExecutionException( "artifact [" + artifact.getId() + "] defined an overly constrained version range" ); } }
if(null == project.getFile() || !project.getFile().exists()) return Pair.pair(Pair.pair(new DefaultArtifactVersion(NO_VERSION_DEFINED),new PomVersionElement(PomVersionElement.MANAGEMENT,null)),rewriter); rewriter = new MavenProjectRewriter(project.getFile()); MavenProjectRewriter mavenRewriter = (MavenProjectRewriter) rewriter; ampsVersionInPom = new DefaultArtifactVersion(NO_VERSION_DEFINED); if(project.hasParent() && NO_VERSION_DEFINED.equalsIgnoreCase(ampsManagementVersionInPom.toString()) && NO_VERSION_DEFINED.equalsIgnoreCase(ampsVersionInPom.toString())) return getVersionAndRewriter(project.getParent()); else if(!NO_VERSION_DEFINED.equalsIgnoreCase(ampsManagementVersionInPom.toString()))
private DefaultArtifactVersion getPomVersion(String ampsVersionOrProperty, MavenProject project) { DefaultArtifactVersion ampsVersionInPom = null; if(StringUtils.isNotBlank(ampsVersionOrProperty) && ampsVersionOrProperty.startsWith("$")) { String propName = StringUtils.substringBetween(ampsVersionOrProperty,"${","}"); if(StringUtils.isNotBlank(propName)) { ampsVersionInPom = new DefaultArtifactVersion(project.getProperties().getProperty(propName,"0.0")); } } else if(StringUtils.isNotBlank(ampsVersionOrProperty)) { ampsVersionInPom = new DefaultArtifactVersion(ampsVersionOrProperty); } else { ampsVersionInPom = new DefaultArtifactVersion(NO_VERSION_DEFINED); } return ampsVersionInPom; }
private boolean matchJdkVersionRange( String jdk ) throws InvalidVersionSpecificationException { VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); return jdkVersionRange.containsVersion( jdkVersion ); }