001package org.apache.maven.project.artifact; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.Collections; 023import java.util.List; 024 025import org.apache.maven.artifact.DefaultArtifact; 026import org.apache.maven.artifact.handler.ArtifactHandler; 027import org.apache.maven.model.Dependency; 028import org.apache.maven.model.DependencyManagement; 029import org.apache.maven.project.MavenProject; 030 031public class ProjectArtifact 032 extends DefaultArtifact 033 implements ArtifactWithDependencies 034{ 035 private MavenProject project; 036 037 public ProjectArtifact( MavenProject project ) 038 { 039 super( project.getGroupId(), project.getArtifactId(), project.getVersion(), null, "pom", null, 040 new PomArtifactHandler() ); 041 this.project = project; 042 setFile( project.getFile() ); 043 setResolved( true ); 044 } 045 046 public MavenProject getProject() 047 { 048 return project; 049 } 050 051 public List<Dependency> getDependencies() 052 { 053 return project.getDependencies(); 054 } 055 056 public List<Dependency> getManagedDependencies() 057 { 058 DependencyManagement depMngt = project.getDependencyManagement(); 059 return ( depMngt != null ) ? depMngt.getDependencies() : Collections.<Dependency>emptyList(); 060 } 061 062 static class PomArtifactHandler 063 implements ArtifactHandler 064 { 065 public String getClassifier() 066 { 067 return null; 068 } 069 070 public String getDirectory() 071 { 072 return null; 073 } 074 075 public String getExtension() 076 { 077 return "pom"; 078 } 079 080 public String getLanguage() 081 { 082 return "none"; 083 } 084 085 public String getPackaging() 086 { 087 return "pom"; 088 } 089 090 public boolean isAddedToClasspath() 091 { 092 return false; 093 } 094 095 public boolean isIncludesDependencies() 096 { 097 return false; 098 } 099 } 100}