本文整理汇总了Java中org.apache.maven.model.Plugin.getVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Plugin.getVersion方法的具体用法?Java Plugin.getVersion怎么用?Java Plugin.getVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.Plugin
的用法示例。
在下文中一共展示了Plugin.getVersion方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findVersion
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
private String findVersion(String groupId, String artifactId) {
String key = groupId + ":" + artifactId;
List<Plugin> plugins = new ArrayList<Plugin>();
if (project != null) {
List<Plugin> bld = project.getOriginalMavenProject().getBuildPlugins();
if (bld != null) {
plugins.addAll(bld);
}
if (project.getOriginalMavenProject().getPluginManagement() != null) {
List<Plugin> pm = project.getOriginalMavenProject().getPluginManagement().getPlugins();
if (pm != null) {
plugins.addAll(pm);
}
}
}
for (Plugin plg : plugins) {
if (key.equals(plg.getKey())) {
return plg.getVersion();
}
}
return null;
}
示例2: visitBuildPlugin
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
@Override
public void visitBuildPlugin( Plugin plugin )
{
if ( isExternal( plugin.getLocation( "" ) ) )
return;
String groupId = plugin.getGroupId();
String artifactId = plugin.getArtifactId();
String version = plugin.getVersion();
if ( StringUtils.isEmpty( groupId ) )
groupId = "org.apache.maven.plugins";
if ( StringUtils.isEmpty( version ) )
version = Artifact.DEFAULT_VERSION;
Artifact pluginArtifact = new DefaultArtifact( groupId, artifactId, version );
artifacts.add( pluginArtifact );
}
示例3: convertPlugin
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
private static MavenPlugin convertPlugin(Plugin plugin) {
List<MavenPluginExecution> executions =
plugin.getExecutions().stream().map(MavenModelUtil::convertExecution).collect(toList());
List<MavenKey> dependecies =
plugin
.getDependencies()
.stream()
.map(
dependency ->
new MavenKey(
dependency.getGroupId(),
dependency.getArtifactId(),
dependency.getVersion()))
.collect(toList());
return new MavenPlugin(
plugin.getGroupId(),
plugin.getArtifactId(),
plugin.getVersion(),
false,
convertConfiguration(plugin.getConfiguration()),
executions,
dependecies);
}
示例4: lookupPluginUpdates
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
/**
* {@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 );
}
示例5: lookupPluginUpdates
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
/**
* {@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 = Boolean.TRUE.equals( 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 );
}
示例6: apply
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
@Override
public boolean apply(Plugin p) {
String version = p.getVersion();
version = propertyResolver.expandPropertyReferences(version);
return version != null && MavenVersionUtil.isSnapshot(version);
}
示例7: getVersion
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
@Override
public String getVersion(final Plugin origin) {
return origin.getVersion();
}
示例8: addPluginAssociations
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
/**
* Takes a list of {@link org.apache.maven.model.Plugin} instances and adds associations to properties used to
* define versions of the plugin artifact or any of the plugin dependencies specified in the pom.
*
* @param helper Our helper.
* @param expressionEvaluator Our expression evaluator.
* @param result The map of {@link org.codehaus.mojo.versions.api.PropertyVersionsBuilder} keyed by property name.
* @param plugins The list of {@link org.apache.maven.model.Plugin}.
* @throws ExpressionEvaluationException if an expression cannot be evaluated.
*/
private static void addPluginAssociations( VersionsHelper helper, ExpressionEvaluator expressionEvaluator,
Map<String, PropertyVersionsBuilder> result, List<Plugin> plugins )
throws ExpressionEvaluationException
{
if ( plugins == null )
{
return;
}
for ( Plugin plugin : plugins )
{
String version = plugin.getVersion();
if ( version != null && version.contains( "${" ) && version.indexOf( '}' ) != -1 )
{
version = StringUtils.deleteWhitespace( version );
for ( PropertyVersionsBuilder property : result.values() )
{
// any of these could be defined by a property
final String propertyRef = "${" + property.getName() + "}";
if ( version.contains( propertyRef ) )
{
String groupId = plugin.getGroupId();
if ( groupId == null || groupId.trim().length() == 0 )
{
// group Id has a special default
groupId = APACHE_MAVEN_PLUGINS_GROUPID;
}
else
{
groupId = (String) expressionEvaluator.evaluate( groupId );
}
String artifactId = plugin.getArtifactId();
if ( artifactId == null || artifactId.trim().length() == 0 )
{
// malformed pom
continue;
}
else
{
artifactId = (String) expressionEvaluator.evaluate( artifactId );
}
// might as well capture the current value
VersionRange versionRange =
VersionRange.createFromVersion( (String) expressionEvaluator.evaluate( plugin.getVersion() ) );
property.addAssociation( helper.createPluginArtifact( groupId, artifactId, versionRange ),
true );
if ( !propertyRef.equals( version ) )
{
addBounds( property, version, propertyRef, versionRange.toString() );
}
}
}
}
addDependencyAssocations( helper, expressionEvaluator, result, plugin.getDependencies(), true );
}
}
示例9: toArtifact
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
private Artifact toArtifact(Plugin plugin) {
return new DefaultArtifact(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null, Constants.MAVEN_PLUGIN_TYPE, null, getArtifactHandler());
}
示例10: addPluginAssociations
import org.apache.maven.model.Plugin; //导入方法依赖的package包/类
/**
* Takes a list of {@link org.apache.maven.model.Plugin} instances and adds associations to properties used to
* define versions of the plugin artifact or any of the plugin dependencies specified in the pom.
*
* @param helper Our helper.
* @param expressionEvaluator Our expression evaluator.
* @param result The map of {@link org.codehaus.mojo.versions.api.PropertyVersionsBuilder} keyed by property name.
* @param plugins The list of {@link org.apache.maven.model.Plugin}.
* @throws ExpressionEvaluationException if an expression cannot be evaluated.
*/
private static void addPluginAssociations( VersionsHelper helper, ExpressionEvaluator expressionEvaluator,
Map<String, PropertyVersionsBuilder> result, List<Plugin> plugins )
throws ExpressionEvaluationException
{
if ( plugins == null )
{
return;
}
for ( Plugin plugin : plugins )
{
String version = plugin.getVersion();
if ( version != null && version.contains( "${" ) && version.indexOf( '}' ) != -1 )
{
version = StringUtils.deleteWhitespace( version );
for ( PropertyVersionsBuilder property : result.values() )
{
// any of these could be defined by a property
final String propertyRef = "${" + property.getName() + "}";
if ( version.contains( propertyRef ) )
{
String groupId = plugin.getGroupId();
if ( groupId == null || groupId.trim().length() == 0 )
{
// group Id has a special default
groupId = APACHE_MAVEN_PLUGINS_GROUPID;
}
else
{
groupId = (String) expressionEvaluator.evaluate( groupId );
}
String artifactId = plugin.getArtifactId();
if ( artifactId == null || artifactId.trim().length() == 0 )
{
// malformed pom
continue;
}
else
{
artifactId = (String) expressionEvaluator.evaluate( artifactId );
}
// might as well capture the current value
VersionRange versionRange = VersionRange.createFromVersion(
(String) expressionEvaluator.evaluate( plugin.getVersion() ) );
property.addAssociation( helper.createPluginArtifact( groupId, artifactId, versionRange ),
true );
if ( !propertyRef.equals( version ) )
{
addBounds( property, version, propertyRef, versionRange.toString() );
}
}
}
}
addDependencyAssocations( helper, expressionEvaluator, result, plugin.getDependencies(), true );
}
}