本文整理汇总了Java中org.apache.maven.artifact.Artifact.getVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Artifact.getVersion方法的具体用法?Java Artifact.getVersion怎么用?Java Artifact.getVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.Artifact
的用法示例。
在下文中一共展示了Artifact.getVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJsonDependencies
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
public static ArrayNode getJsonDependencies(List<Artifact> artifacts, List<Dependency> directDependencies) {
HashMap<String, String> requirements = new HashMap<String, String>(directDependencies.size());
for (Dependency dep : directDependencies) {
requirements.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion());
}
ObjectMapper mapper = new ObjectMapper();
ArrayNode arrayNode = mapper.createArrayNode();
for (Artifact art : artifacts) {
ObjectNode artNode = depToJsonNode(mapper, art);
String requirement;
requirement = requirements.get(art.getGroupId() + ":" + art.getArtifactId());
// Temporary workaround for transitive dependencies
if (requirement == null){
requirement = art.getVersion();
}
artNode.put("requirement", requirement);
arrayNode.add(artNode);
}
return arrayNode;
}
示例2: shadedSourcesArtifactFile
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private File shadedSourcesArtifactFile()
{
Artifact artifact = project.getArtifact();
String shadedName;
if ( project.getBuild().getFinalName() != null )
{
shadedName = project.getBuild().getFinalName() + "-sources." + artifact.getArtifactHandler().getExtension();
}
else
{
shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-sources."
+ artifact.getArtifactHandler().getExtension();
}
return new File( outputDirectory, shadedName );
}
示例3: shadedTestArtifactFile
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private File shadedTestArtifactFile()
{
Artifact artifact = project.getArtifact();
String shadedName;
if ( project.getBuild().getFinalName() != null )
{
shadedName = project.getBuild().getFinalName() + "-tests." + artifact.getArtifactHandler().getExtension();
}
else
{
shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-tests."
+ artifact.getArtifactHandler().getExtension();
}
return new File( outputDirectory, shadedName );
}
示例4: execute
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
public void execute() throws MojoExecutionException {
if (project.getPackaging() != "jar") {
return;
}
Artifact artifact = project.getArtifact();
String contractorCoordinates = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
+ artifact.getVersion();
try (ContractStorage contractStorage = ContractStorage.instance()) {
contractStorage.saveContractor(artifact.getFile(), contractorCoordinates);
} catch (IOException e) {
logger.warn("Can not store contracts of " + contractorCoordinates, e);
}
}
示例5: getJUnitVersion
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private String getJUnitVersion(MavenProject prj) {
String juVersion = "";
for (Artifact a : prj.getArtifacts()) {
if ("junit".equals(a.getGroupId()) && ("junit".equals(a.getArtifactId()) || "junit-dep".equals(a.getArtifactId()))) { //junit-dep see #214238
String version = a.getVersion();
if (version != null && new ComparableVersion(version).compareTo(new ComparableVersion("4.8")) >= 0) {
return "JUNIT4"; //NOI18N
}
if (version != null && new ComparableVersion(version).compareTo(new ComparableVersion("3.8")) >= 0) {
return "JUNIT3"; //NOI18N
}
}
}
return juVersion;
}
示例6: usingJUnit4
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private boolean usingJUnit4(MavenProject prj) { // SUREFIRE-724
for (Artifact a : prj.getArtifacts()) {
if ("junit".equals(a.getGroupId()) && ("junit".equals(a.getArtifactId()) || "junit-dep".equals(a.getArtifactId()))) { //junit-dep see #214238
String version = a.getVersion();
if (version != null && new ComparableVersion(version).compareTo(new ComparableVersion("4.8")) >= 0) {
return true;
}
}
}
return false;
}
示例7: usingJUnit4
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private boolean usingJUnit4() { // SUREFIRE-724
for (Artifact a : proj.getLookup().lookup(NbMavenProject.class).getMavenProject().getArtifacts()) {
if ("junit".equals(a.getGroupId()) && ("junit".equals(a.getArtifactId()) || "junit-dep".equals(a.getArtifactId()))) { //junit-dep see #214238
String version = a.getVersion();
if (version != null && new ComparableVersion(version).compareTo(new ComparableVersion("4.8")) >= 0) {
return true;
}
}
}
return false;
}
示例8: obtainManagedState
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private int obtainManagedState(MavenDependencyNode dependencyNode) {
if (proj == null) {
return GraphNode.UNMANAGED;
}
DependencyManagement dm = proj.getDependencyManagement();
if (dm == null) {
return GraphNode.UNMANAGED;
}
@SuppressWarnings("unchecked")
List<Dependency> deps = dm.getDependencies();
if (deps == null) {
return GraphNode.UNMANAGED;
}
Artifact artifact = dependencyNode.getArtifact();
String id = artifact.getArtifactId();
String groupId = artifact.getGroupId();
String version = artifact.getVersion();
for (Dependency dep : deps) {
if (id.equals(dep.getArtifactId()) && groupId.equals(dep.getGroupId())) {
if (!version.equals(dep.getVersion())) {
return GraphNode.OVERRIDES_MANAGED;
} else {
return GraphNode.MANAGED;
}
}
}
return GraphNode.UNMANAGED;
}
示例9: getFormattedFileName
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
/**
* Builds the file name. If removeVersion is set, then the file name must be
* reconstructed from the artifactId, Classifier (if used) and Type.
* Otherwise, this method returns the artifact file name.
*
* @param artifact
* File to be formatted.
* @param removeVersion
* Specifies if the version should be removed from the file name.
* @return Formatted file name in the format
* artifactId-[version]-[classifier].[type]
*/
public static String getFormattedFileName( Artifact artifact, boolean removeVersion )
{
String destFileName = null;
// if there is a file and we aren't stripping the version, just get the
// name directly
if ( artifact.getFile() != null && !removeVersion )
{
destFileName = artifact.getFile().getName();
}
else
// if offline
{
String versionString = null;
if ( !removeVersion )
{
versionString = "-" + artifact.getVersion();
}
else
{
versionString = "";
}
String classifierString = "";
if ( StringUtils.isNotEmpty( artifact.getClassifier() ) )
{
classifierString = "-" + artifact.getClassifier();
}
destFileName = artifact.getArtifactId() + versionString + classifierString + "."
+ artifact.getArtifactHandler().getExtension();
}
return destFileName;
}
示例10: assertNoConflict
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
void assertNoConflict(Artifact artifact) throws MojoExecutionException {
Optional<String> builtInVersion = dependencies.stream()
.filter(dependency -> dependency.getGroupId().equals(artifact.getGroupId()))
.filter(dependency -> dependency.getArtifactId().equals(artifact.getArtifactId()))
.map(Artifact::getVersion)
.findFirst();
if (builtInVersion.isPresent() && ! builtInVersion.get().equals(artifact.getVersion())) {
String artifactName = artifact.getGroupId() + ":" + artifact.getArtifactId();
throw new MojoExecutionException("Conflicting dependencies: Your project includes " + artifactName +
" version " + artifact.getVersion() + " but the promagent-maven-plugin is built with version " + builtInVersion.get());
}
}
示例11: failOnVersionConflict
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private static void failOnVersionConflict(Artifact artifact, List<Artifact> knownArtifacts, String pluginArtifactId) throws MojoExecutionException {
Optional<String> conflictingVersion = knownArtifacts.stream()
.filter(artifactMatcherWithoutVersion(artifact))
.filter(artifactMatcherWithVersion(artifact).negate()) // same version -> not conflicting
.findFirst()
.map(Artifact::getVersion);
if (conflictingVersion.isPresent()) {
String artifactName = artifact.getGroupId() + artifact.getArtifactId();
throw new MojoExecutionException("version conflict in " + pluginArtifactId + ": " + artifactName + " found in version " + artifact.getVersion() + " and version " + conflictingVersion.get());
}
}
示例12: shadedArtifactFileWithClassifier
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private File shadedArtifactFileWithClassifier()
{
Artifact artifact = project.getArtifact();
final String shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName + "."
+ artifact.getArtifactHandler().getExtension();
return new File( outputDirectory, shadedName );
}
示例13: shadedSourceArtifactFileWithClassifier
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private File shadedSourceArtifactFileWithClassifier()
{
Artifact artifact = project.getArtifact();
final String shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName
+ "-sources." + artifact.getArtifactHandler().getExtension();
return new File( outputDirectory, shadedName );
}
示例14: shadedTestArtifactFileWithClassifier
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private File shadedTestArtifactFileWithClassifier()
{
Artifact artifact = project.getArtifact();
final String shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName
+ "-tests." + artifact.getArtifactHandler().getExtension();
return new File( outputDirectory, shadedName );
}
示例15: getTcId
import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private static String getTcId(Artifact artifact) {
return artifact.getGroupId() + ":" + artifact.getArtifactId() +
":" + artifact.getVersion();
}