org.apache.maven.artifact.versioning.InvalidVersionSpecificationException Java Examples
The following examples show how to use
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CdiContainerUnderTest.java From deltaspike with Apache License 2.0 | 6 votes |
/** * Verify if the runtime is using the following CdiImplementation * * @param cdiImplementation * @param versionRange * optional - If not defined it will used the range defined on {@link CdiImplementation} * @return * @throws InvalidVersionSpecificationException */ public static boolean isCdiVersion(CdiImplementation cdiImplementation, String versionRange) throws InvalidVersionSpecificationException { Class implementationClass = tryToLoadClassForName(cdiImplementation.getImplementationClassName()); if (implementationClass == null) { return false; } VersionRange range = VersionRange.createFromVersionSpec(versionRange == null ? cdiImplementation .getVersionRange() : versionRange); String containerVersion = getJarSpecification(implementationClass); return containerVersion != null && range.containsVersion(new DefaultArtifactVersion(containerVersion)); }
Example #2
Source File: ResolvableDependency.java From java-specialagent with Apache License 2.0 | 6 votes |
List<Dependency> resolveVersions(final MavenProject project, final Log log) throws InvalidVersionSpecificationException, MojoExecutionException { if (resolvedVersions != null) return resolvedVersions; if (isSingleVersion()) return resolvedVersions = Collections.singletonList(MavenUtil.newDependency(getGroupId(), getArtifactId(), getVersion())); final ResolvableDependency versionDependency = isOwnVersion() ? this : ResolvableDependency.parse(getVersion()); resolvedVersions = new ArrayList<>(); final SortedSet<DefaultArtifactVersion> versions = resolveVersions(project, log, versionDependency); final VersionRange versionRange = VersionRange.createFromVersionSpec(versionDependency.getVersion()); for (final DefaultArtifactVersion version : versions) if (versionRange.containsVersion(version)) resolvedVersions.add(MavenUtil.newDependency(getGroupId(), getArtifactId(), version.toString())); return resolvedVersions; }
Example #3
Source File: MavenUtils.java From mvn-golang with Apache License 2.0 | 6 votes |
/** * Parse string containing artifact record * * @param record string containing record, must not be null * @param handler artifact handler for created artifact, must not be null * @return new created artifact from the record, must not be null * @throws InvalidVersionSpecificationException it will be thrown if version * format is wrong * @throws IllegalArgumentException it will be thrown if record can't be * recognized as artifact record */ @Nonnull public static Artifact parseArtifactRecord( @Nonnull final String record, @Nonnull final ArtifactHandler handler ) throws InvalidVersionSpecificationException { final Matcher matcher = ARTIFACT_RECORD_PATTERN.matcher(record.trim()); if (matcher.find()) { return new DefaultArtifact( matcher.group(1), matcher.group(2), VersionRange.createFromVersion(matcher.group(3)), matcher.group(4).isEmpty() ? null : matcher.group(4), matcher.group(5).isEmpty() ? null : matcher.group(5), matcher.group(6).isEmpty() ? null : matcher.group(6), handler); } throw new IllegalArgumentException("Can't recognize record as artifact: " + record); }
Example #4
Source File: DataflowDependencyManager.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * Returns the encoded version range from the given project's POM, or {@code null} if no version * is specified. * * @return the version range or {@code null} if a version range is not specified * @throws IllegalStateException if the encoded version range is not a valid version specification */ private VersionRange getActualDataflowVersionRange(IProject project) { Model model = getModelFromProject(project); if (model != null) { Dependency dependency = getDataflowDependencyFromModel(model); if (dependency != null) { String version = dependency.getVersion(); if (!Strings.isNullOrEmpty(version)) { try { return VersionRange.createFromVersionSpec(version); } catch (InvalidVersionSpecificationException ex) { String message = String.format("Could not create version range from existing version %s", version); throw new IllegalStateException(message, ex); } } } } return null; }
Example #5
Source File: ConfluenceDeployMojo.java From maven-confluence-plugin with Apache License 2.0 | 6 votes |
/** * * @param projectId * @param dependencyManagement * @return * @throws ProjectBuildingException */ private Map<String,Artifact> createManagedVersionMap(String projectId, DependencyManagement dependencyManagement) throws ProjectBuildingException { Map<String,Artifact> map; if (dependencyManagement != null && dependencyManagement.getDependencies() != null) { map = new HashMap<>(); for (Dependency d : dependencyManagement.getDependencies()) { try { VersionRange versionRange = VersionRange.createFromVersionSpec(d.getVersion()); Artifact artifact = factory.createDependencyArtifact(d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope()); map.put(d.getManagementKey(), artifact); } catch (InvalidVersionSpecificationException e) { throw new ProjectBuildingException(projectId, "Unable to parse version '" + d.getVersion() + "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e); } } } else { map = Collections.emptyMap(); } return map; }
Example #6
Source File: AbstractVersionsDependencyUpdaterMojo.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
/** * Try to find the dependency artifact that matches the given dependency. * * @param dependency Dependency * @throws MojoExecutionException Mojo execution exception * @return Artifact * @since 1.0-alpha-3 */ protected Artifact toArtifact( Dependency dependency ) throws MojoExecutionException { Artifact artifact = findArtifact( dependency ); if ( artifact == null ) { try { return getHelper().createDependencyArtifact( dependency ); } catch ( InvalidVersionSpecificationException e ) { throw new MojoExecutionException( e.getMessage(), e ); } } return artifact; }
Example #7
Source File: PomHelper.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
/** * Checks if two versions or ranges have an overlap. * * @param leftVersionOrRange the 1st version number or range to test * @param rightVersionOrRange the 2nd version number or range to test * @return true if both versions have an overlap * @throws InvalidVersionSpecificationException if the versions can't be parsed to a range */ public static boolean isVersionOverlap( String leftVersionOrRange, String rightVersionOrRange ) throws InvalidVersionSpecificationException { VersionRange pomVersionRange = createVersionRange( leftVersionOrRange ); if ( !pomVersionRange.hasRestrictions() ) { return true; } VersionRange oldVersionRange = createVersionRange( rightVersionOrRange ); if ( !oldVersionRange.hasRestrictions() ) { return true; } VersionRange result = oldVersionRange.restrict( pomVersionRange ); return result.hasRestrictions(); }
Example #8
Source File: PomHelper.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
private static VersionRange createVersionRange( String versionOrRange ) throws InvalidVersionSpecificationException { VersionRange versionRange = VersionRange.createFromVersionSpec( versionOrRange ); if ( versionRange.getRecommendedVersion() != null ) { versionRange = VersionRange.createFromVersionSpec( "[" + versionOrRange + "]" ); } return versionRange; }
Example #9
Source File: VersionUtil.java From phantomjs-maven-plugin with MIT License | 5 votes |
public static boolean isWithin(String version, String versionSpec) { boolean within = false; try { within = VersionUtil.isWithin(version, VersionRange.createFromVersionSpec(versionSpec)); } catch (InvalidVersionSpecificationException e) { LOGGER.warn(INVALID_VERSION_SPECIFICATION, versionSpec); } return within; }
Example #10
Source File: RangeResolver.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
private void handleVersionWithRange( Dependency d ) { try { VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); // If its a range then try to use a matching version... if ( versionRange.hasRestrictions() ) { final List<ArtifactVersion> versions = getVersions( new SimpleProjectRef( d.getGroupId(), d.getArtifactId() ) ); final ArtifactVersion result = versionRange.matchVersion( versions ); logger.debug( "Resolved range for dependency {} got versionRange {} and potential replacement of {} ", d, versionRange, result ); if ( result != null ) { d.setVersion( result.toString() ); } else { logger.warn( "Unable to find replacement for range." ); } } } catch ( InvalidVersionSpecificationException e ) { throw new ManipulationUncheckedException( new ManipulationException( "Invalid range", e ) ); } }
Example #11
Source File: RangeResolver.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
private void handleVersionWithRange( Plugin p ) { try { VersionRange versionRange = VersionRange.createFromVersionSpec( p.getVersion() ); // If its a range then try to use a matching version... if ( versionRange.hasRestrictions() ) { final List<ArtifactVersion> versions = getVersions( new SimpleProjectRef( p.getGroupId(), p.getArtifactId() ) ); final ArtifactVersion result = versionRange.matchVersion( versions ); logger.debug( "Resolved range for plugin {} got versionRange {} and potential replacement of {} ", p, versionRange, result ); if ( result != null ) { p.setVersion( result.toString() ); } else { logger.warn( "Unable to find replacement for range." ); } } } catch ( InvalidVersionSpecificationException e ) { throw new ManipulationUncheckedException( new ManipulationException( "Invalid range", e ) ); } }
Example #12
Source File: ArtifactInfo.java From pgpverify-maven-plugin with Apache License 2.0 | 5 votes |
private static String versionSpecPrepare(String versionSpec) throws InvalidVersionSpecificationException { if (versionSpec.length() == 0 || "*".equals(versionSpec)) { // any version return "[0.0.0,)"; } if (versionSpec.contains("*")) { throw new InvalidVersionSpecificationException("Invalid maven version range: " + versionSpec); } return versionSpec; }
Example #13
Source File: ArtifactInfo.java From pgpverify-maven-plugin with Apache License 2.0 | 5 votes |
public ArtifactInfo(String strArtifact, KeyInfo keyInfo) { String[] split = strArtifact.split(":"); String groupId = split.length > 0 ? split[0].trim().toLowerCase(Locale.US) : ""; String artifactId = split.length > 1 ? split[1].trim().toLowerCase(Locale.US) : ""; String packaging = ""; String version = ""; if (split.length == 3) { String item = split[2].trim().toLowerCase(Locale.US); if (PACKAGING.matcher(item).matches()) { packaging = item; } else { version = item; } } else if (split.length == 4) { packaging = split[2].trim().toLowerCase(Locale.US); version = split[3].trim().toLowerCase(Locale.US); } else { packaging = ""; } try { groupIdPattern = Pattern.compile(patternPrepare(groupId)); artifactIdPattern = Pattern.compile(patternPrepare(artifactId)); packagingPattern = Pattern.compile(patternPrepare(packaging)); versionRange = VersionRange.createFromVersionSpec(versionSpecPrepare(version)); } catch (InvalidVersionSpecificationException | PatternSyntaxException e) { throw new IllegalArgumentException("Invalid artifact definition: " + strArtifact, e); } this.keyInfo = keyInfo; }
Example #14
Source File: AbstractVersionsReportRenderer.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
private Set<String> getVersionsInRange( Property property, PropertyVersions versions, ArtifactVersion[] artifactVersions ) { VersionRange range; Set<String> rangeVersions = new HashSet<>(); ArtifactVersion[] tmp; if ( property.getVersion() != null ) { try { range = VersionRange.createFromVersionSpec( property.getVersion() ); tmp = versions.getAllUpdates( range ); } catch ( InvalidVersionSpecificationException e ) { tmp = artifactVersions; } } else { tmp = artifactVersions; } for ( int i = 0; i < tmp.length; i++ ) { rangeVersions.add( tmp[i].toString() ); } return rangeVersions; }
Example #15
Source File: CompatibilityTestMojo.java From java-specialagent with Apache License 2.0 | 5 votes |
private void assertCompatibility(final List<CompatibilitySpec> compatibilitySpecs, final boolean shouldPass) throws DependencyResolutionException, IOException, LifecycleExecutionException, MojoExecutionException, InvalidVersionSpecificationException { getLog().info("Running " + (shouldPass ? "PASS" : "FAIL") + " compatibility tests..."); for (final CompatibilitySpec compatibilitySpec : compatibilitySpecs) { String versionSpec = null; int numSpecs = -1; final int size = compatibilitySpec.getDependencies().size(); final List<Dependency>[] resolvedVersions = new List[size]; for (int i = 0; i < size; ++i) { final ResolvableDependency dependency = compatibilitySpec.getDependencies().get(i); final boolean isSingleVersion = dependency.isSingleVersion(); if (!isSingleVersion) { if (versionSpec == null) versionSpec = dependency.getVersion(); else if (!versionSpec.equals(dependency.getVersion())) throw new MojoExecutionException("Version across all dependencies in a <pass> or <fail> spec must be equal"); } resolvedVersions[i] = dependency.resolveVersions(getProject(), getLog()); if (!isSingleVersion) { if (numSpecs == -1) numSpecs = resolvedVersions[i].size(); else if (numSpecs != resolvedVersions[i].size()) throw new MojoExecutionException("Expeted the same number of resolved versions for: " + compatibilitySpec); } } if (numSpecs == -1) numSpecs = 1; for (int i = 0; i < numSpecs; ++i) { final Dependency[] dependencies = new Dependency[resolvedVersions.length]; for (int j = 0; j < resolvedVersions.length; ++j) dependencies[j] = resolvedVersions[j].get(resolvedVersions[j].size() == numSpecs ? i : 0); assertCompatibility(dependencies, shouldPass); } } }
Example #16
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException { String version = plugin.getVersion(); version = version == null ? "LATEST" : version; getLog().debug( "Checking " + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) + " for updates newer than " + version ); VersionRange versionRange = VersionRange.createFromVersion( version ); final boolean includeSnapshots = allowSnapshots; final ArtifactVersions pluginArtifactVersions = lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ), true ); Set<Dependency> pluginDependencies = new TreeSet<Dependency>( new DependencyComparator() ); if ( plugin.getDependencies() != null ) { pluginDependencies.addAll( plugin.getDependencies() ); } Map<Dependency, ArtifactVersions> pluginDependencyDetails = lookupDependenciesUpdates( pluginDependencies, false ); return new PluginUpdatesDetails( pluginArtifactVersions, pluginDependencyDetails, includeSnapshots ); }
Example #17
Source File: DataflowDependencyManager.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static VersionRange allVersions() { try { return VersionRange.createFromVersionSpec("[1.0.0,)"); } catch (InvalidVersionSpecificationException e) { throw new IllegalStateException( "Could not create constant version Range [1.0.0,)", e); } }
Example #18
Source File: CompatibilityTestMojo.java From java-specialagent with Apache License 2.0 | 5 votes |
@Override void doExecute() throws MojoExecutionException { try { if ((passCompatibility != null || failCompatibility != null) && (passes != null || fails != null)) throw new MojoExecutionException("<{pass/fail}Compatibility> cannot be used in conjuction with <passes> or <fails>"); if (passCompatibility != null) passes = shortFormToLongForm(passCompatibility); if (failCompatibility != null) fails = shortFormToLongForm(failCompatibility); boolean wasRun = false; if (passes != null && (wasRun = true)) assertCompatibility(passes, true); if (fails != null && (wasRun = true)) assertCompatibility(fails, false); if (failAtEnd && errors.size() > 0) throw new MojoExecutionException("Failed compatibility tests:\n" + AssembleUtil.toIndentedString(errors)); if (wasRun) { // Reset the dependencies back to original resolveDependencies(); return; } final List<Dependency> fingerprintedDependencies = getFingerprintedDependencies(); if (fingerprintedDependencies.size() > 0) throw new MojoExecutionException("No compatibility tests were run for verions of:\n" + AssembleUtil.toIndentedString(fingerprintedDependencies)); } catch (final DependencyResolutionException | IOException | InvalidVersionSpecificationException | LifecycleExecutionException e) { throw new MojoExecutionException(e.getMessage(), e); } }
Example #19
Source File: MavenUtil.java From Decca with MIT License | 5 votes |
public Artifact getArtifact(String groupId, String artifactId, String versionRange, String type, String classifier, String scope) { try { return mojo.factory.createDependencyArtifact(groupId, artifactId, VersionRange.createFromVersionSpec(versionRange), type, classifier, scope); } catch (InvalidVersionSpecificationException e) { getLog().error("cant create Artifact!", e); return null; } }
Example #20
Source File: DataflowDependencyManagerTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testGetProjectMajorVersion() throws InvalidVersionSpecificationException { Dependency pinnedDep = pinnedDataflowDependency(); when(model.getDependencies()).thenReturn(ImmutableList.of(pinnedDep)); ArtifactVersion latestVersion = new DefaultArtifactVersion("1.2.3"); when( artifactRetriever.getLatestReleaseVersion(DataflowMavenCoordinates.GROUP_ID, DataflowMavenCoordinates.ARTIFACT_ID, VersionRange.createFromVersionSpec(pinnedDep.getVersion()))).thenReturn(latestVersion); assertEquals(MajorVersion.ONE, manager.getProjectMajorVersion(project)); }
Example #21
Source File: ArtifactRetrieverIntegrationTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testGetGuava19() throws InvalidVersionSpecificationException { VersionRange range = VersionRange.createFromVersionSpec("[1.0,19.0]"); ArtifactVersion guava = ArtifactRetriever.DEFAULT.getLatestReleaseVersion("com.google.guava", "guava", range); Assert.assertEquals(19, guava.getMajorVersion()); Assert.assertEquals(0, guava.getMinorVersion()); }
Example #22
Source File: FlattenModelResolver.java From flatten-maven-plugin with Apache License 2.0 | 5 votes |
private static boolean isRestrictedVersionRange( String version, String groupId, String artifactId ) throws UnresolvableModelException { try { return VersionRange.createFromVersionSpec( version ).hasRestrictions(); } catch ( InvalidVersionSpecificationException e ) { throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e ); } }
Example #23
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public Artifact createDependencyArtifact( Dependency dependency ) throws InvalidVersionSpecificationException { return createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() == null ? VersionRange.createFromVersionSpec( "[0,]" ) : VersionRange.createFromVersionSpec( dependency.getVersion() ), dependency.getType(), dependency.getClassifier(), dependency.getScope(), dependency.isOptional() ); }
Example #24
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException { getLog().debug( "Checking " + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) + " for updates newer than " + dependency.getVersion() ); VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() ); return lookupArtifactVersions( createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange, dependency.getType(), dependency.getClassifier(), dependency.getScope() ), usePluginRepositories ); }
Example #25
Source File: UseReleasesMojo.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
private void useReleases( ModifiedPomXMLEventReader pom, MavenProject project ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { String version = project.getVersion(); Matcher versionMatcher = matchSnapshotRegex.matcher( version ); if ( versionMatcher.matches() ) { String releaseVersion = versionMatcher.group( 1 ); VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( releaseVersion ); } catch ( InvalidVersionSpecificationException e ) { throw new MojoExecutionException( "Invalid version range specification: " + version, e ); } Artifact artifact = artifactFactory.createDependencyArtifact( getProject().getParent().getGroupId(), getProject().getParent().getArtifactId(), versionRange, "pom", null, null ); if ( !isIncluded( artifact ) ) { return; } getLog().debug( "Looking for a release of " + toString( project ) ); // Force releaseVersion version because org.apache.maven.artifact.metadata.MavenMetadataSource does not // retrieve release version if provided snapshot version. artifact.setVersion( releaseVersion ); ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); if ( !allowRangeMatching ) // standard behaviour { if ( versions.containsVersion( releaseVersion ) ) { if ( PomHelper.setProjectParentVersion( pom, releaseVersion ) ) { getLog().info( "Updated " + toString( project ) + " to version " + releaseVersion ); } } else if ( failIfNotReplaced ) { throw new NoSuchElementException( "No matching release of " + toString( project ) + " found for update." ); } } else { ArtifactVersion finalVersion = null; for ( ArtifactVersion proposedVersion : versions.getVersions( false ) ) { if ( proposedVersion.toString().startsWith( releaseVersion ) ) { getLog().debug( "Found matching version for " + toString( project ) + " to version " + releaseVersion ); finalVersion = proposedVersion; } } if ( finalVersion != null ) { if ( PomHelper.setProjectParentVersion( pom, finalVersion.toString() ) ) { getLog().info( "Updated " + toString( project ) + " to version " + finalVersion.toString() ); } } else { getLog().info( "No matching release of " + toString( project ) + " to update via rangeMatching." ); if ( failIfNotReplaced ) { throw new NoSuchElementException( "No matching release of " + toString( project ) + " found for update via rangeMatching." ); } } } } }
Example #26
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public Map<Plugin, PluginUpdatesDetails> lookupPluginsUpdates( Set<Plugin> plugins, boolean allowSnapshots ) throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException { // Create the request for details collection for parallel lookup... final List<Callable<PluginPluginUpdatesDetails>> requestsForDetails = new ArrayList<Callable<PluginPluginUpdatesDetails>>( plugins.size() ); for ( final Plugin plugin : plugins ) { requestsForDetails.add( new PluginLookup( plugin, allowSnapshots ) ); } final Map<Plugin, PluginUpdatesDetails> pluginUpdates = new TreeMap<Plugin, PluginUpdatesDetails>( new PluginComparator() ); // Lookup details in parallel... final ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); try { final List<Future<PluginPluginUpdatesDetails>> responseForDetails = executor.invokeAll( requestsForDetails ); // Construct the final results... for ( final Future<PluginPluginUpdatesDetails> details : responseForDetails ) { final PluginPluginUpdatesDetails pud = details.get(); pluginUpdates.put( pud.getPlugin(), pud.getPluginUpdatesDetails() ); } } catch ( final ExecutionException ee ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " + ee.getMessage(), ee ); } catch ( final InterruptedException ie ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " + ie.getMessage(), ie ); } finally { executor.shutdownNow(); } return pluginUpdates; }
Example #27
Source File: PluginUpdatesReport.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
/** * generates an empty report in case there are no sources to generate a report with * * @param locale the locale to generate the report for. * @param sink the report formatting tool */ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException { Set<Plugin> pluginManagement = new TreeSet<>( new PluginComparator() ); if ( haveBuildPluginManagementPlugins() ) { pluginManagement.addAll( getProject().getBuild().getPluginManagement().getPlugins() ); } Set<Plugin> plugins = new TreeSet<>( new PluginComparator() ); if ( haveBuildPlugins() ) { plugins.addAll( getProject().getBuild().getPlugins() ); } plugins = removePluginManagment( plugins, pluginManagement ); try { Map<Plugin, PluginUpdatesDetails> pluginUpdates = getHelper().lookupPluginsUpdates( plugins, getAllowSnapshots() ); Map<Plugin, PluginUpdatesDetails> pluginManagementUpdates = getHelper().lookupPluginsUpdates( pluginManagement, getAllowSnapshots() ); for ( String format : formats ) { if ( "html".equals( format ) ) { PluginUpdatesRenderer renderer = new PluginUpdatesRenderer( sink, getI18n(), getOutputName(), locale, pluginUpdates, pluginManagementUpdates ); renderer.render(); } else if ( "xml".equals( format ) ) { File outputDir = new File(getProject().getBuild().getDirectory()); if (!outputDir.exists()) { outputDir.mkdirs(); } String outputFile = outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; PluginUpdatesXmlRenderer xmlGenerator = new PluginUpdatesXmlRenderer( pluginUpdates, pluginManagementUpdates, outputFile ); xmlGenerator.render(); } } } catch ( InvalidVersionSpecificationException | ArtifactMetadataRetrievalException e ) { throw new MavenReportException( e.getMessage(), e ); } }
Example #28
Source File: CassandraServer.java From geowave with Apache License 2.0 | 4 votes |
private StartGeoWaveCluster(final int numNodes, final int memory, final String directory) { super(); startWaitSeconds = 180; rpcAddress = "127.0.0.1"; rpcPort = 9160; jmxPort = 7199; startNativeTransport = true; nativeTransportPort = 9042; listenAddress = "127.0.0.1"; storagePort = 7000; stopPort = 8081; stopKey = "cassandra-maven-plugin"; maxMemory = memory; cassandraDir = new File(directory, NODE_DIRECTORY_PREFIX); logLevel = "ERROR"; project = new MavenProject(); project.setFile(cassandraDir); Field f; try { f = StartCassandraClusterMojo.class.getDeclaredField("clusterSize"); f.setAccessible(true); f.set(this, numNodes); f = AbstractCassandraMojo.class.getDeclaredField("pluginArtifact"); f.setAccessible(true); final DefaultArtifact a = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec("version"), null, "type", null, new DefaultArtifactHandler()); a.setFile(cassandraDir); f.set(this, a); f = AbstractCassandraMojo.class.getDeclaredField("pluginDependencies"); f.setAccessible(true); f.set(this, new ArrayList<>()); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException | InvalidVersionSpecificationException e) { LOGGER.error("Unable to initialize start cassandra cluster", e); } }
Example #29
Source File: CassandraServer.java From geowave with Apache License 2.0 | 4 votes |
private StartGeoWaveStandalone(final int memory, final String directory) { super(); startWaitSeconds = 180; rpcAddress = "127.0.0.1"; rpcPort = 9160; jmxPort = 7199; startNativeTransport = true; nativeTransportPort = 9042; listenAddress = "127.0.0.1"; storagePort = 7000; stopPort = 8081; stopKey = "cassandra-maven-plugin"; maxMemory = memory; cassandraDir = new File(directory); logLevel = "ERROR"; project = new MavenProject(); project.setFile(cassandraDir); Field f; try { f = AbstractCassandraMojo.class.getDeclaredField("pluginArtifact"); f.setAccessible(true); final DefaultArtifact a = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec("version"), null, "type", null, new DefaultArtifactHandler()); a.setFile(cassandraDir); f.set(this, a); f = AbstractCassandraMojo.class.getDeclaredField("pluginDependencies"); f.setAccessible(true); f.set(this, new ArrayList<>()); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException | InvalidVersionSpecificationException e) { LOGGER.error("Unable to initialize start cassandra cluster", e); } }
Example #30
Source File: MavenUtils.java From mvn-golang with Apache License 2.0 | 4 votes |
/** * Scan project dependencies to find artifacts generated by mvn golang * project. * * @param mavenProject maven project, must not be null * @param includeTestDependencies flag to process dependencies marked for test * phases * @param mojo calling mojo, must not be null * @param session maven session, must not be null * @param execution maven execution, must not be null * @param resolver artifact resolver, must not be null * @param remoteRepositories list of remote repositories, must not be null * @return list of files found in artifacts generated by mvn golang plugin * @throws ArtifactResolverException exception thrown if some artifact can't * be resolved */ @Nonnull @MustNotContainNull public static List<Tuple<Artifact, File>> scanForMvnGoArtifacts( @Nonnull final MavenProject mavenProject, final boolean includeTestDependencies, @Nonnull final AbstractMojo mojo, @Nonnull final MavenSession session, @Nonnull final MojoExecution execution, @Nonnull final ArtifactResolver resolver, @Nonnull @MustNotContainNull final List<ArtifactRepository> remoteRepositories ) throws ArtifactResolverException { final List<Tuple<Artifact, File>> result = new ArrayList<>(); // final String phase = execution.getLifecyclePhase(); final Set<String> alreadyFoundArtifactRecords = new HashSet<>(); MavenProject currentProject = mavenProject; while (currentProject != null && !Thread.currentThread().isInterrupted()) { final Set<Artifact> projectDependencies = currentProject.getDependencyArtifacts(); final List<Artifact> artifacts = new ArrayList<>(projectDependencies == null ? Collections.emptySet() : projectDependencies); mojo.getLog().debug("Detected dependency artifacts: " + artifacts); while (!artifacts.isEmpty() && !Thread.currentThread().isInterrupted()) { final Artifact artifact = artifacts.remove(0); if (Artifact.SCOPE_TEST.equals(artifact.getScope()) && !includeTestDependencies) { continue; } if (artifact.getType().equals(AbstractGolangMojo.GOARTIFACT_PACKAGING)) { final ArtifactResult artifactResult = resolver.resolveArtifact(makeResolveArtifactProjectBuildingRequest(session, remoteRepositories), artifact); final File zipFillePath = artifactResult.getArtifact().getFile(); mojo.getLog().debug("Detected MVN-GOLANG marker inside ZIP dependency: " + artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getVersion() + ':' + artifact.getType()); if (ZipUtil.containsEntry(zipFillePath, GolangMvnInstallMojo.MVNGOLANG_DEPENDENCIES_FILE)) { final byte[] artifactFlagFile = ZipUtil.unpackEntry(zipFillePath, GolangMvnInstallMojo.MVNGOLANG_DEPENDENCIES_FILE, StandardCharsets.UTF_8); for (final String str : new String(artifactFlagFile, StandardCharsets.UTF_8).split("\\R")) { if (str.trim().isEmpty() || alreadyFoundArtifactRecords.contains(str)) { continue; } mojo.getLog().debug("Adding mvn-golang dependency: " + str); alreadyFoundArtifactRecords.add(str); try { artifacts.add(parseArtifactRecord(str, new MvnGolangArtifactHandler())); } catch (InvalidVersionSpecificationException ex) { throw new ArtifactResolverException("Can't make artifact: " + str, ex); } } } final File artifactFile = artifactResult.getArtifact().getFile(); mojo.getLog().debug("Artifact file: " + artifactFile); if (doesContainFile(result, artifactFile)) { mojo.getLog().debug("Artifact file ignored as duplication: " + artifactFile); } else { result.add(Tuple.of(artifact, artifactFile)); } } } currentProject = currentProject.hasParent() ? currentProject.getParent() : null; } return result; }