PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/subprojects/core/src/main/java/org/gradle/api/artifacts/dsl/RepositoryHandler.java

http://github.com/gradle/gradle
Java | 234 lines | 22 code | 16 blank | 196 comment | 0 complexity | b3004d8922b0aef97ecb7bcdd367c7f4 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, LGPL-2.1
  1. /*
  2. * Copyright 2009 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.gradle.api.artifacts.dsl;
  17. import groovy.lang.Closure;
  18. import org.gradle.api.Action;
  19. import org.gradle.api.artifacts.ArtifactRepositoryContainer;
  20. import org.gradle.api.artifacts.repositories.FlatDirectoryArtifactRepository;
  21. import org.gradle.api.artifacts.repositories.IvyArtifactRepository;
  22. import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
  23. import java.util.Map;
  24. /**
  25. * A {@code RepositoryHandler} manages a set of repositories, allowing repositories to be defined and queried.
  26. */
  27. public interface RepositoryHandler extends ArtifactRepositoryContainer {
  28. /**
  29. * Adds a resolver that looks into a number of directories for artifacts. The artifacts are expected to be located in the
  30. * root of the specified directories. The resolver ignores any group/organization information specified in the
  31. * dependency section of your build script. If you only use this kind of resolver you might specify your
  32. * dependencies like <code>":junit:4.4"</code> instead of <code>"junit:junit:4.4"</code>.
  33. *
  34. * The following parameter are accepted as keys for the map:
  35. *
  36. * <table summary="Shows property keys and associated values">
  37. * <tr><th>Key</th>
  38. * <th>Description of Associated Value</th></tr>
  39. * <tr><td><code>name</code></td>
  40. * <td><em>(optional)</em> The name of the repository.
  41. * The default is a Hash value of the rootdir paths. The name is used in the console output,
  42. * to point to information related to a particular repository. A name must be unique amongst a repository group.</td></tr>
  43. * <tr><td><code>dirs</code></td>
  44. * <td>Specifies a list of rootDirs where to look for dependencies. These are evaluated as per {@link org.gradle.api.Project#files(Object...)}</td></tr>
  45. * </table>
  46. *
  47. * <p>Examples:
  48. * <pre autoTested=''>
  49. * repositories {
  50. * flatDir name: 'libs', dirs: "$projectDir/libs"
  51. * flatDir dirs: ["$projectDir/libs1", "$projectDir/libs2"]
  52. * }
  53. * </pre>
  54. * </p>
  55. *
  56. * @param args The arguments used to configure the repository.
  57. * @return the added resolver
  58. * @throws org.gradle.api.InvalidUserDataException In the case neither rootDir nor rootDirs is specified of if both
  59. * are specified.
  60. */
  61. FlatDirectoryArtifactRepository flatDir(Map<String, ?> args);
  62. /**
  63. * Adds an configures a repository which will look for dependencies in a number of local directories.
  64. *
  65. * @param configureClosure The closure to execute to configure the repository.
  66. * @return The repository.
  67. */
  68. FlatDirectoryArtifactRepository flatDir(Closure configureClosure);
  69. /**
  70. * Adds an configures a repository which will look for dependencies in a number of local directories.
  71. *
  72. * @param action The action to execute to configure the repository.
  73. * @return The repository.
  74. */
  75. FlatDirectoryArtifactRepository flatDir(Action<? super FlatDirectoryArtifactRepository> action);
  76. /**
  77. * Adds a repository which looks in Bintray's JCenter repository for dependencies.
  78. * <p>
  79. * The URL used to access this repository is {@literal "https://jcenter.bintray.com/"}.
  80. * The behavior of this repository is otherwise the same as those added by {@link #maven(org.gradle.api.Action)}.
  81. * <p>
  82. * Examples:
  83. * <pre autoTested="">
  84. * repositories {
  85. * jcenter {
  86. * artifactUrls = ["http://www.mycompany.com/artifacts1", "http://www.mycompany.com/artifacts2"]
  87. * }
  88. * jcenter {
  89. * name = "nonDefaultName"
  90. * artifactUrls = ["http://www.mycompany.com/artifacts1"]
  91. * }
  92. * }
  93. * </pre>
  94. *
  95. * @param action a configuration action
  96. * @return the added repository
  97. */
  98. MavenArtifactRepository jcenter(Action<? super MavenArtifactRepository> action);
  99. /**
  100. * Adds a repository which looks in Bintray's JCenter repository for dependencies.
  101. * <p>
  102. * The URL used to access this repository is {@literal "https://jcenter.bintray.com/"}.
  103. * The behavior of this repository is otherwise the same as those added by {@link #maven(org.gradle.api.Action)}.
  104. * <p>
  105. * Examples:
  106. * <pre autoTested="">
  107. * repositories {
  108. * jcenter()
  109. * }
  110. * </pre>
  111. *
  112. * @return the added resolver
  113. * @see #jcenter(Action)
  114. */
  115. MavenArtifactRepository jcenter();
  116. /**
  117. * Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is
  118. * {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#MAVEN_CENTRAL_URL}.
  119. *
  120. * <p>The following parameter are accepted as keys for the map:
  121. *
  122. * <table summary="Shows property keys and associated values">
  123. * <tr><th>Key</th>
  124. * <th>Description of Associated Value</th></tr>
  125. * <tr><td><code>name</code></td>
  126. * <td><em>(optional)</em> The name of the repository. The default is
  127. * {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_CENTRAL_REPO_NAME} is used as the name. A name
  128. * must be unique amongst a repository group.
  129. * </td></tr>
  130. * <tr><td><code>artifactUrls</code></td>
  131. * <td>A single jar repository or a collection of jar repositories containing additional artifacts not found in the Maven central repository.
  132. * But be aware that the POM must exist in Maven central.
  133. * The provided values are evaluated as per {@link org.gradle.api.Project#uri(Object)}.</td></tr>
  134. * </table>
  135. *
  136. * <p>Examples:
  137. * <pre autoTested="">
  138. * repositories {
  139. * mavenCentral artifactUrls: ["http://www.mycompany.com/artifacts1", "http://www.mycompany.com/artifacts2"]
  140. * mavenCentral name: "nonDefaultName", artifactUrls: ["http://www.mycompany.com/artifacts1"]
  141. * }
  142. * </pre>
  143. * </p>
  144. *
  145. * @param args A list of urls of repositories to look for artifacts only.
  146. * @return the added repository
  147. */
  148. MavenArtifactRepository mavenCentral(Map<String, ?> args);
  149. /**
  150. * Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is
  151. * {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#MAVEN_CENTRAL_URL}. The name of the repository is
  152. * {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_CENTRAL_REPO_NAME}.
  153. *
  154. * <p>Examples:
  155. * <pre autoTested="">
  156. * repositories {
  157. * mavenCentral()
  158. * }
  159. * </pre>
  160. * </p>
  161. *
  162. * @return the added resolver
  163. * @see #mavenCentral(java.util.Map)
  164. */
  165. MavenArtifactRepository mavenCentral();
  166. /**
  167. * Adds a repository which looks in the local Maven cache for dependencies. The name of the repository is
  168. * {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_LOCAL_REPO_NAME}.
  169. *
  170. * <p>Examples:
  171. * <pre autoTested="">
  172. * repositories {
  173. * mavenLocal()
  174. * }
  175. * </pre>
  176. * </p>
  177. * <p>
  178. * The location for the repository is determined as follows (in order of precedence):
  179. * <ol>
  180. * <li>The value of system property 'maven.repo.local' if set;</li>
  181. * <li>The value of element &lt;localRepository&gt; of <code>~/.m2/settings.xml</code> if this file exists and element is set;</li>
  182. * <li>The value of element &lt;localRepository&gt; of <code>$M2_HOME/conf/settings.xml</code> (where <code>$M2_HOME</code> is the value of the environment variable with that name) if this file exists and element is set;</li>
  183. * <li>The path <code>~/.m2/repository</code>.</li>
  184. * </ol>
  185. * </p>
  186. *
  187. * @return the added resolver
  188. */
  189. MavenArtifactRepository mavenLocal();
  190. /**
  191. * Adds and configures a Maven repository. Newly created instance of {@code MavenArtifactRepository} is passed as an argument to the closure.
  192. *
  193. * @param closure The closure to use to configure the repository.
  194. * @return The added repository.
  195. */
  196. MavenArtifactRepository maven(Closure closure);
  197. /**
  198. * Adds and configures a Maven repository.
  199. *
  200. * @param action The action to use to configure the repository.
  201. * @return The added repository.
  202. */
  203. MavenArtifactRepository maven(Action<? super MavenArtifactRepository> action);
  204. /**
  205. * Adds and configures an Ivy repository. Newly created instance of {@code IvyArtifactRepository} is passed as an argument to the closure.
  206. *
  207. * @param closure The closure to use to configure the repository.
  208. * @return The added repository.
  209. */
  210. IvyArtifactRepository ivy(Closure closure);
  211. /**
  212. * Adds and configures an Ivy repository.
  213. *
  214. * @param action The action to use to configure the repository.
  215. * @return The added repository.
  216. */
  217. IvyArtifactRepository ivy(Action<? super IvyArtifactRepository> action);
  218. }