| 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 java.io.File; |
| 22 |
import java.util.Collection; |
| 23 |
import java.util.Collections; |
| 24 |
import java.util.HashMap; |
| 25 |
import java.util.Map; |
| 26 |
|
| 27 |
import org.apache.maven.artifact.handler.ArtifactHandler; |
| 28 |
import org.apache.maven.artifact.handler.DefaultArtifactHandler; |
| 29 |
import org.apache.maven.artifact.metadata.ArtifactMetadata; |
| 30 |
import org.apache.maven.plugin.testing.stubs.ArtifactStub; |
| 31 |
|
| 32 |
public class DeployArtifactStub extends ArtifactStub { |
| 33 |
private Map<Object, ArtifactMetadata> metadataMap; |
| 34 |
|
| 35 |
private File file; |
| 36 |
|
| 37 |
private boolean release; |
| 38 |
|
| 39 |
private String extension; |
| 40 |
|
| 41 |
public String getArtifactId() { |
| 42 |
return "maven-deploy-test"; |
| 43 |
} |
| 44 |
|
| 45 |
public String getGroupId() { |
| 46 |
return "org.apache.maven.test"; |
| 47 |
} |
| 48 |
|
| 49 |
public String getVersion() { |
| 50 |
return "1.0-SNAPSHOT"; |
| 51 |
} |
| 52 |
|
| 53 |
public String getBaseVersion() { |
| 54 |
return getVersion(); |
| 55 |
} |
| 56 |
|
| 57 |
@Override |
| 58 |
public String getType() { |
| 59 |
return "jar"; |
| 60 |
} |
| 61 |
|
| 62 |
public void setFile(File file) { |
| 63 |
this.file = file; |
| 64 |
} |
| 65 |
|
| 66 |
public File getFile() { |
| 67 |
return file; |
| 68 |
} |
| 69 |
|
| 70 |
public ArtifactHandler getArtifactHandler() { |
| 71 |
return new DefaultArtifactHandler() { |
| 72 |
public String getExtension() { |
| 73 |
if (extension == null) { |
| 74 |
extension = "jar"; |
| 75 |
} |
| 76 |
return extension; |
| 77 |
} |
| 78 |
}; |
| 79 |
} |
| 80 |
|
| 81 |
public void setArtifactHandlerExtension(String extension) { |
| 82 |
this.extension = extension; |
| 83 |
} |
| 84 |
|
| 85 |
public void addMetadata(ArtifactMetadata metadata) { |
| 86 |
if (metadataMap == null) { |
| 87 |
metadataMap = new HashMap<>(); |
| 88 |
} |
| 89 |
|
| 90 |
ArtifactMetadata m = metadataMap.get(metadata.getKey()); |
| 91 |
if (m != null) { |
| 92 |
m.merge(metadata); |
| 93 |
} else { |
| 94 |
metadataMap.put(metadata.getKey(), metadata); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
public Collection<ArtifactMetadata> getMetadataList() { |
| 99 |
return metadataMap == null ? Collections.emptyList() : metadataMap.values(); |
| 100 |
} |
| 101 |
|
| 102 |
public boolean isRelease() { |
| 103 |
return release; |
| 104 |
} |
| 105 |
|
| 106 |
public void setRelease(boolean release) { |
| 107 |
this.release = release; |
| 108 |
} |
| 109 |
|
| 110 |
/* |
| 111 |
public boolean isSnapshot() |
| 112 |
{ |
| 113 |
return false; |
| 114 |
} |
| 115 |
*/ |
| 116 |
} |