1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.deployment
;
13 import java
.util
.ArrayList
;
14 import java
.util
.Collection
;
15 import java
.util
.Collections
;
17 import org
.eclipse
.aether
.RepositorySystem
;
18 import org
.eclipse
.aether
.RepositorySystemSession
;
19 import org
.eclipse
.aether
.RequestTrace
;
20 import org
.eclipse
.aether
.artifact
.Artifact
;
21 import org
.eclipse
.aether
.metadata
.Metadata
;
22 import org
.eclipse
.aether
.repository
.RemoteRepository
;
25 * A request to deploy artifacts and their accompanying metadata into the a remote repository.
27 * @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest)
29 public final class DeployRequest
32 private Collection
<Artifact
> artifacts
= Collections
.emptyList();
34 private Collection
<Metadata
> metadata
= Collections
.emptyList();
36 private RemoteRepository repository
;
38 private RequestTrace trace
;
41 * Creates an uninitialized request.
43 public DeployRequest()
48 * Gets the artifact to deploy.
50 * @return The artifacts to deploy, never {@code null}.
52 public Collection
<Artifact
> getArtifacts()
58 * Sets the artifacts to deploy.
60 * @param artifacts The artifacts to deploy, may be {@code null}.
61 * @return This request for chaining, never {@code null}.
63 public DeployRequest
setArtifacts( Collection
<Artifact
> artifacts
)
65 if ( artifacts
== null )
67 this.artifacts
= Collections
.emptyList();
71 this.artifacts
= artifacts
;
77 * Adds the specified artifacts for deployment.
79 * @param artifact The artifact to add, may be {@code null}.
80 * @return This request for chaining, never {@code null}.
82 public DeployRequest
addArtifact( Artifact artifact
)
84 if ( artifact
!= null )
86 if ( artifacts
.isEmpty() )
88 artifacts
= new ArrayList
<Artifact
>();
90 artifacts
.add( artifact
);
96 * Gets the metadata to deploy.
98 * @return The metadata to deploy, never {@code null}.
100 public Collection
<Metadata
> getMetadata()
106 * Sets the metadata to deploy.
108 * @param metadata The metadata to deploy, may be {@code null}.
109 * @return This request for chaining, never {@code null}.
111 public DeployRequest
setMetadata( Collection
<Metadata
> metadata
)
113 if ( metadata
== null )
115 this.metadata
= Collections
.emptyList();
119 this.metadata
= metadata
;
125 * Adds the specified metadata for deployment.
127 * @param metadata The metadata to add, may be {@code null}.
128 * @return This request for chaining, never {@code null}.
130 public DeployRequest
addMetadata( Metadata metadata
)
132 if ( metadata
!= null )
134 if ( this.metadata
.isEmpty() )
136 this.metadata
= new ArrayList
<Metadata
>();
138 this.metadata
.add( metadata
);
144 * Gets the repository to deploy to.
146 * @return The repository to deploy to or {@code null} if not set.
148 public RemoteRepository
getRepository()
154 * Sets the repository to deploy to.
156 * @param repository The repository to deploy to, may be {@code null}.
157 * @return This request for chaining, never {@code null}.
159 public DeployRequest
setRepository( RemoteRepository repository
)
161 this.repository
= repository
;
166 * Gets the trace information that describes the higher level request/operation in which this request is issued.
168 * @return The trace information about the higher level operation or {@code null} if none.
170 public RequestTrace
getTrace()
176 * Sets the trace information that describes the higher level request/operation in which this request is issued.
178 * @param trace The trace information about the higher level operation, may be {@code null}.
179 * @return This request for chaining, never {@code null}.
181 public DeployRequest
setTrace( RequestTrace trace
)
188 public String
toString()
190 return getArtifacts() + ", " + getMetadata() + " > " + getRepository();