View Javadoc
1   package org.apache.maven.plugin.deploy.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.Artifact;
23  import org.apache.maven.artifact.metadata.ArtifactMetadata;
24  import org.apache.maven.artifact.repository.ArtifactRepository;
25  import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
26  import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
27  import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
28  
29  public class ArtifactRepositoryStub
30      implements ArtifactRepository
31  {
32      private boolean blacklisted;
33      
34      private ArtifactRepositoryLayout layout;
35      
36      private String url;
37      
38      private String basedir = System.getProperty( "basedir" );
39  
40      public String pathOf( Artifact artifact )
41      {
42          return getLayout().pathOf( artifact );
43      }
44      
45      public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
46      {
47          return getLayout().pathOfRemoteRepositoryMetadata( artifactMetadata );
48      }
49      
50      public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
51      {
52          return getLayout().pathOfLocalRepositoryMetadata( metadata, repository );
53      }
54      
55      public String getUrl()
56      {
57          return url;
58      }
59      
60      public void setAppendToUrl( String dir )
61      {
62          this.url = "file://" + basedir + "/target/remote-repo/" + dir;
63      }
64      
65      public String getBasedir()
66      {
67          return basedir;
68      }
69      
70      public String getProtocol()
71      {
72          return "file";
73      }
74      
75      public String getId()
76      {
77          return "deploy-test";
78      }
79      
80      public ArtifactRepositoryPolicy getSnapshots()
81      {
82          return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
83                                               ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
84      }
85      
86      public ArtifactRepositoryPolicy getReleases()
87      {
88          return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
89                                               ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
90      }
91      
92      public ArtifactRepositoryLayout getLayout()
93      {
94          if( layout != null )
95          {
96              return layout;
97          }
98          else
99          {
100             return new DefaultRepositoryLayout();
101         }
102     }
103     
104     public String getKey()
105     {
106         return getId();
107     }
108 
109     public boolean isUniqueVersion()
110     {
111         return false;
112     }
113    
114     public void setBlacklisted( boolean blackListed )
115     {
116         this.blacklisted = blackListed;
117     }
118 
119     public boolean isBlacklisted()
120     {
121         return blacklisted;
122     }
123 }