RepositoryConventionPlugin.groovy 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2004-present the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * https://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, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package io.spring.gradle.convention;
  17. import org.gradle.api.Plugin
  18. import org.gradle.api.Project
  19. class RepositoryConventionPlugin implements Plugin<Project> {
  20. @Override
  21. void apply(Project project) {
  22. String[] forceMavenRepositories = ((String) project.findProperty("forceMavenRepositories"))?.split(',')
  23. boolean isImplicitSnapshotRepository = forceMavenRepositories == null && Utils.isSnapshot(project)
  24. boolean isImplicitMilestoneRepository = forceMavenRepositories == null && Utils.isMilestone(project)
  25. boolean isSnapshot = isImplicitSnapshotRepository || forceMavenRepositories?.contains('snapshot')
  26. boolean isMilestone = isImplicitMilestoneRepository || forceMavenRepositories?.contains('milestone')
  27. project.repositories {
  28. if (forceMavenRepositories?.contains('local')) {
  29. mavenLocal()
  30. }
  31. maven {
  32. name = 'shibboleth'
  33. url = 'https://build.shibboleth.net/nexus/content/repositories/releases/'
  34. content {
  35. includeGroupByRegex('org\\.opensaml.*')
  36. includeGroupByRegex('net\\.shibboleth.*')
  37. }
  38. }
  39. mavenCentral()
  40. if (isSnapshot) {
  41. maven {
  42. name = 'artifactory-snapshot'
  43. if (project.hasProperty('artifactoryUsername')) {
  44. credentials {
  45. username project.artifactoryUsername
  46. password project.artifactoryPassword
  47. }
  48. }
  49. url = 'https://repo.spring.io/snapshot/'
  50. }
  51. }
  52. if (isSnapshot || isMilestone) {
  53. maven {
  54. name = 'artifactory-milestone'
  55. if (project.hasProperty('artifactoryUsername')) {
  56. credentials {
  57. username project.artifactoryUsername
  58. password project.artifactoryPassword
  59. }
  60. }
  61. url = 'https://repo.spring.io/milestone/'
  62. }
  63. }
  64. maven {
  65. name = 'artifactory-release'
  66. if (project.hasProperty('artifactoryUsername')) {
  67. credentials {
  68. username project.artifactoryUsername
  69. password project.artifactoryPassword
  70. }
  71. }
  72. content {
  73. excludeGroup('net.minidev')
  74. }
  75. url = 'https://repo.spring.io/release/'
  76. }
  77. }
  78. }
  79. }