| 1 |
/* |
| 2 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
* or more contributor license agreements. See the NOTICE file |
| 4 |
* distributed with this work for additional information |
| 5 |
* regarding copyright ownership. The ASF licenses this file |
| 6 |
* to you under the Apache License, Version 2.0 (the |
| 7 |
* "License"); you may not use this file except in compliance |
| 8 |
* with the License. You may obtain a copy of the License at |
| 9 |
* |
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
* |
| 12 |
* Unless required by applicable law or agreed to in writing, |
| 13 |
* software distributed under the License is distributed on an |
| 14 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
* KIND, either express or implied. See the License for the |
| 16 |
* specific language governing permissions and limitations |
| 17 |
* under the License. |
| 18 |
*/ |
| 19 |
package org.apache.maven.plugins.deploy.stubs; |
| 20 |
|
| 21 |
import org.apache.maven.artifact.Artifact; |
| 22 |
import org.apache.maven.artifact.metadata.ArtifactMetadata; |
| 23 |
import org.apache.maven.artifact.repository.ArtifactRepository; |
| 24 |
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; |
| 25 |
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; |
| 26 |
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; |
| 27 |
import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; |
| 28 |
|
| 29 |
public class ArtifactRepositoryStub extends StubArtifactRepository { |
| 30 |
private boolean blacklisted; |
| 31 |
|
| 32 |
private ArtifactRepositoryLayout layout; |
| 33 |
|
| 34 |
private String url; |
| 35 |
|
| 36 |
private final String basedir = System.getProperty("basedir"); |
| 37 |
|
| 38 |
public ArtifactRepositoryStub() { |
| 39 |
super(null); |
| 40 |
} |
| 41 |
|
| 42 |
public ArtifactRepositoryStub(String dir) { |
| 43 |
super(dir); |
| 44 |
} |
| 45 |
|
| 46 |
public String pathOf(Artifact artifact) { |
| 47 |
return getLayout().pathOf(artifact); |
| 48 |
} |
| 49 |
|
| 50 |
public String pathOfRemoteRepositoryMetadata(ArtifactMetadata artifactMetadata) { |
| 51 |
return getLayout().pathOfRemoteRepositoryMetadata(artifactMetadata); |
| 52 |
} |
| 53 |
|
| 54 |
public String pathOfLocalRepositoryMetadata(ArtifactMetadata metadata, ArtifactRepository repository) { |
| 55 |
return getLayout().pathOfLocalRepositoryMetadata(metadata, repository); |
| 56 |
} |
| 57 |
|
| 58 |
public String getUrl() { |
| 59 |
return url; |
| 60 |
} |
| 61 |
|
| 62 |
public void setAppendToUrl(String dir) { |
| 63 |
this.url = "file://" + basedir + "/target/remote-repo/" + dir; |
| 64 |
} |
| 65 |
|
| 66 |
public String getBasedir() { |
| 67 |
return basedir; |
| 68 |
} |
| 69 |
|
| 70 |
public String getProtocol() { |
| 71 |
return "file"; |
| 72 |
} |
| 73 |
|
| 74 |
public String getId() { |
| 75 |
return "deploy-test"; |
| 76 |
} |
| 77 |
|
| 78 |
public ArtifactRepositoryPolicy getSnapshots() { |
| 79 |
return new ArtifactRepositoryPolicy( |
| 80 |
true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE); |
| 81 |
} |
| 82 |
|
| 83 |
public ArtifactRepositoryPolicy getReleases() { |
| 84 |
return new ArtifactRepositoryPolicy( |
| 85 |
true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE); |
| 86 |
} |
| 87 |
|
| 88 |
public ArtifactRepositoryLayout getLayout() { |
| 89 |
if (layout != null) { |
| 90 |
return layout; |
| 91 |
} else { |
| 92 |
return new DefaultRepositoryLayout(); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
public String getKey() { |
| 97 |
return getId(); |
| 98 |
} |
| 99 |
|
| 100 |
public boolean isUniqueVersion() { |
| 101 |
return false; |
| 102 |
} |
| 103 |
|
| 104 |
public void setBlacklisted(boolean blackListed) { |
| 105 |
this.blacklisted = blackListed; |
| 106 |
} |
| 107 |
|
| 108 |
public boolean isBlacklisted() { |
| 109 |
return blacklisted; |
| 110 |
} |
| 111 |
|
| 112 |
// @Override |
| 113 |
public boolean isBlocked() { |
| 114 |
return false; |
| 115 |
} |
| 116 |
|
| 117 |
// @Override |
| 118 |
public void setBlocked(boolean b) {} |
| 119 |
} |