Java Code Examples for org.apache.maven.artifact.Artifact#getBaseVersion()
The following examples show how to use
org.apache.maven.artifact.Artifact#getBaseVersion() .
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: ExtensionDefinitionFactory.java From nifi-maven with Apache License 2.0 | 6 votes |
private Set<ServiceAPIDefinition> getProvidedServiceAPIs(final ExtensionType extensionType, final Class<?> extensionClass) throws ClassNotFoundException { if (extensionType != ExtensionType.CONTROLLER_SERVICE) { return Collections.emptySet(); } final Set<ServiceAPIDefinition> serviceApis = new HashSet<>(); final Class<?> controllerServiceClass = Class.forName("org.apache.nifi.controller.ControllerService", false, extensionClassLoader); for (final Class<?> implementedInterface : extensionClass.getInterfaces()) { if (controllerServiceClass.isAssignableFrom(implementedInterface)) { final ClassLoader interfaceClassLoader = implementedInterface.getClassLoader(); if (interfaceClassLoader instanceof ExtensionClassLoader) { final Artifact interfaceNarArtifact = ((ExtensionClassLoader) interfaceClassLoader).getNarArtifact(); final ServiceAPIDefinition serviceDefinition = new StandardServiceAPIDefinition(implementedInterface.getName(), interfaceNarArtifact.getGroupId(), interfaceNarArtifact.getArtifactId(), interfaceNarArtifact.getBaseVersion()); serviceApis.add(serviceDefinition); } } } return serviceApis; }
Example 2
Source File: BarMojo.java From incubator-batchee with Apache License 2.0 | 6 votes |
private static String artifactPath(final Artifact artifact) { final StringBuilder sb = new StringBuilder(); sb.append(artifact.getArtifactId()); sb.append("-"); if (artifact.hasClassifier()) { sb.append(artifact.getClassifier()); sb.append("-"); } if (artifact.getBaseVersion() != null) { sb.append(artifact.getBaseVersion()); } else if (artifact.getVersion() != null) { sb.append(artifact.getVersion()); } else { sb.append(artifact.getVersionRange().toString()); } sb.append('.').append(artifact.getType()); return sb.toString(); }
Example 3
Source File: AbstractSwarmMojo.java From wildfly-swarm with Apache License 2.0 | 5 votes |
protected ArtifactSpec artifactToArtifactSpec(Artifact dep) { return new ArtifactSpec(dep.getScope(), dep.getGroupId(), dep.getArtifactId(), dep.getBaseVersion(), dep.getType(), dep.getClassifier(), dep.getFile()); }
Example 4
Source File: AbstractSwarmMojo.java From thorntail with Apache License 2.0 | 5 votes |
protected ArtifactSpec artifactToArtifactSpec(Artifact dep) { return new ArtifactSpec(dep.getScope(), dep.getGroupId(), dep.getArtifactId(), dep.getBaseVersion(), dep.getType(), dep.getClassifier(), dep.getFile()); }
Example 5
Source File: AbstractSwarmMojo.java From thorntail with Apache License 2.0 | 5 votes |
private static ArtifactSpec asBucketKey(Artifact artifact) { return new ArtifactSpec( artifact.getScope(), artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getType(), artifact.getClassifier(), artifact.getFile() ); }
Example 6
Source File: DependenciesMojo.java From mangooio with Apache License 2.0 | 5 votes |
private String coordinates(Artifact artifact) { String classifier = artifact.getClassifier(); String extension = artifact.getType(); String version = snapshotStyle == SnapshotStyle.SNAPSHOT ? artifact.getBaseVersion() : artifact.getVersion(); return artifact.getGroupId() + ":" + artifact.getArtifactId() + (hasText(extension) && (!"jar".equals(extension) || hasText(classifier)) ? ":" + extension : "") + (hasText(classifier) ? ":" + classifier : "") + ":" + version; }
Example 7
Source File: NarMojo.java From nifi-maven with Apache License 2.0 | 5 votes |
private Map<String,ServiceAPIDefinition> getRequiredServiceDefinitions(final Class<?> extensionClass, final Object extensionInstance) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { final Map<String,ServiceAPIDefinition> requiredServiceAPIDefinitions = new HashMap<>(); final Method writeMethod = extensionClass.getMethod("getPropertyDescriptors"); final List<Object> propertyDescriptors = (List<Object>) writeMethod.invoke(extensionInstance); if (propertyDescriptors == null) { return requiredServiceAPIDefinitions; } for (final Object propDescriptor : propertyDescriptors) { final Method nameMethod = propDescriptor.getClass().getMethod("getName"); final String propName = (String) nameMethod.invoke(propDescriptor); final Method serviceDefinitionMethod = propDescriptor.getClass().getMethod("getControllerServiceDefinition"); final Object serviceDefinition = serviceDefinitionMethod.invoke(propDescriptor); if (serviceDefinition == null) { continue; } final Class<?> serviceDefinitionClass = (Class<?>) serviceDefinition; final ExtensionClassLoader extensionClassLoader = (ExtensionClassLoader) serviceDefinitionClass.getClassLoader(); final Artifact narArtifact = extensionClassLoader.getNarArtifact(); final ServiceAPIDefinition serviceAPIDefinition = new StandardServiceAPIDefinition( serviceDefinitionClass.getName(), narArtifact.getGroupId(), narArtifact.getArtifactId(), narArtifact.getBaseVersion() ); requiredServiceAPIDefinitions.put(propName, serviceAPIDefinition); } return requiredServiceAPIDefinitions; }
Example 8
Source File: NarMojo.java From nifi-maven with Apache License 2.0 | 5 votes |
private NarDependency getNarDependency() throws MojoExecutionException { NarDependency narDependency = null; // get nar dependencies FilterArtifacts filter = new FilterArtifacts(); filter.addFilter(new TypeFilter("nar", "")); // start with all artifacts. Set artifacts = project.getArtifacts(); // perform filtering try { artifacts = filter.filter(artifacts); } catch (ArtifactFilterException e) { throw new MojoExecutionException(e.getMessage(), e); } // ensure there is a single nar dependency if (artifacts.size() > 1) { throw new MojoExecutionException("Each NAR represents a ClassLoader. A NAR dependency allows that NAR's ClassLoader to be " + "used as the parent of this NAR's ClassLoader. As a result, only a single NAR dependency is allowed."); } else if (artifacts.size() == 1) { final Artifact artifact = (Artifact) artifacts.iterator().next(); narDependency = new NarDependency(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion()); } return narDependency; }
Example 9
Source File: JarCollector.java From sis with Apache License 2.0 | 5 votes |
/** * Returns the name of the given file. If the given file is a snapshot, then the * {@code "SNAPSHOT"} will be replaced by the timestamp if possible. * * @param file the file from which to get the filename. * @param artifact the artifact that produced the given file. * @return the filename to use. */ private static String getFinalName(final File file, final Artifact artifact) { String filename = file.getName(); final String baseVersion = artifact.getBaseVersion(); if (baseVersion != null) { final int pos = filename.lastIndexOf(baseVersion); if (pos >= 0) { final String version = artifact.getVersion(); if (version != null && !baseVersion.equals(version)) { filename = filename.substring(0, pos) + version + filename.substring(pos + baseVersion.length()); } } } return filename; }
Example 10
Source File: MavenWhiteListQueryImpl.java From netbeans with Apache License 2.0 | 4 votes |
boolean hasOnClassPath(Artifact art) { //construct ID as we do in NetbeansManifestUpdateMojo String id = art.getGroupId() + ":" + art.getArtifactId() + ":" + art.getBaseVersion() + (art.getClassifier() != null ? ":" + art.getClassifier() : ""); return mavenCP.contains(id); }
Example 11
Source File: PackageMojo.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 4 votes |
@Override public void execute() throws MojoExecutionException, MojoFailureException { initProperties(false); final BuildTool tool = new BuildTool(); tool.projectArtifact( this.project.getArtifact().getGroupId(), this.project.getArtifact().getArtifactId(), this.project.getArtifact().getBaseVersion(), this.project.getArtifact().getType(), this.project.getArtifact().getFile()); this.project.getArtifacts() .forEach(dep -> tool.dependency(dep.getScope(), dep.getGroupId(), dep.getArtifactId(), dep.getBaseVersion(), dep.getType(), dep.getClassifier(), dep.getFile(), dep.getDependencyTrail().size() == 2)); List<Resource> resources = this.project.getResources(); for (Resource each : resources) { tool.resourceDirectory(each.getDirectory()); } for (String additionalModule : additionalModules) { File source = new File(this.project.getBuild().getOutputDirectory(), additionalModule); if (source.exists()) { tool.additionalModule(source.getAbsolutePath()); } } tool .properties(this.properties) .mainClass(this.mainClass) .bundleDependencies(this.bundleDependencies); MavenArtifactResolvingHelper resolvingHelper = new MavenArtifactResolvingHelper(this.resolver, this.repositorySystem, this.repositorySystemSession); this.remoteRepositories.forEach(resolvingHelper::remoteRepository); tool.artifactResolvingHelper(resolvingHelper); try { File jar = tool.build(this.project.getBuild().getFinalName(), Paths.get(this.projectBuildDir)); Artifact primaryArtifact = this.project.getArtifact(); ArtifactHandler handler = new DefaultArtifactHandler("jar"); Artifact swarmJarArtifact = new DefaultArtifact( primaryArtifact.getGroupId(), primaryArtifact.getArtifactId(), primaryArtifact.getBaseVersion(), primaryArtifact.getScope(), "jar", "swarm", handler ); swarmJarArtifact.setFile(jar); this.project.addAttachedArtifact(swarmJarArtifact); } catch (Exception e) { throw new MojoFailureException("Unable to create -swarm.jar", e); } }
Example 12
Source File: JarsTxtMojo.java From tomee with Apache License 2.0 | 4 votes |
private String version(final Artifact a) { if (!useTimeStamp && a.getBaseVersion().endsWith("SNAPSHOT")) { return a.getBaseVersion(); } return a.getVersion(); }