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