View Javadoc

1   package org.apache.maven.plugin.idea.stubs;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.artifact.versioning.ArtifactVersion;
23  import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
24  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
25  import org.apache.maven.plugin.testing.stubs.ArtifactStub;
26  
27  import java.io.File;
28  
29  /**
30   * @author Edwin Punzalan
31   */
32  public class IdeaArtifactStub
33      extends ArtifactStub
34  {
35      private String groupId;
36  
37      private String artifactId;
38  
39      private String version;
40  
41      private File file;
42  
43      private String scope;
44  
45  
46      public void setGroupId( String groupId )
47      {
48          this.groupId = groupId;
49      }
50  
51      public String getGroupId()
52      {
53          return groupId;
54      }
55  
56      public void setArtifactId( String artifactId )
57      {
58          this.artifactId = artifactId;
59      }
60  
61      public String getArtifactId()
62      {
63          return artifactId;
64      }
65  
66      public void setVersion( String version )
67      {
68          this.version = version;
69      }
70  
71      public String getVersion()
72      {
73          return version;
74      }
75  
76      public File getFile()
77      {
78          return file;
79      }
80  
81      public void setFile( File file )
82      {
83          this.file = file;
84      }
85  
86      public String getType()
87      {
88          return "jar";
89      }
90  
91      public ArtifactVersion getSelectedVersion()
92          throws OverConstrainedVersionException
93      {
94          return new DefaultArtifactVersion( getVersion() );
95      }
96  
97      public String getId()
98      {
99          return getGroupId() + ":" + getArtifactId() + ":" + getVersion();
100     }
101 
102     public void setScope( String scope )
103     {
104         this.scope = scope;
105     }
106 
107     public String getScope()
108     {
109         if ( scope == null )
110         {
111             scope = super.getScope();
112         }
113 
114         return scope;
115     }
116 }