Skip to content

Commit

Permalink
Fixes #3236 by adding Maven Central like Maven does
Browse files Browse the repository at this point in the history
  • Loading branch information
zendern committed Mar 6, 2021
1 parent 3cb458b commit a7787cb
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def repository_urls
repository_urls += own_buildfile_repository_urls
repository_urls = repository_urls.uniq

return repository_urls unless repository_urls.empty?

[CENTRAL_REPO_URL]
return (repository_urls + [CENTRAL_REPO_URL]).uniq
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,47 @@
https://jcenter.bintray.com
https://dl.bintray.com/magnusja/maven
https://maven.google.com
https://repo.maven.apache.org/maven2
)
)
end

context "when there is only maven central defined" do
let(:buildfile_fixture_name) { "maven_central_only.gradle" }

it "it is not duplicated" do
expect(repository_urls).to match_array(
%w(
https://repo.maven.apache.org/maven2
)
)
end
end

context "when there are private only repository declarations" do
let(:buildfile_fixture_name) { "private_only_repos_build.gradle" }

it "includes private repo as well as maven central as a fallback" do
expect(repository_urls).to match_array(
%w(
https://nexus.noyoucanthaveaccess.net/repository/maven
https://repo.maven.apache.org/maven2
)
)
end
end

context "some of which are for subprojects" do
let(:buildfile_fixture_name) { "subproject_repos.gradle" }

it "doesn't include the subproject declarations" do
expect(repository_urls).
to match_array(%w(https://jcenter.bintray.com))
to match_array(
%w(
https://jcenter.bintray.com
https://repo.maven.apache.org/maven2
)
)
end

context "and this is a subproject" do
Expand All @@ -67,6 +98,7 @@
https://jcenter.bintray.com
https://dl.bintray.com/magnusja/maven
https://maven.google.com
https://repo.maven.apache.org/maven2
)
)
end
Expand All @@ -81,6 +113,7 @@
%w(
https://jcenter.bintray.com
https://maven.google.com
https://repo.maven.apache.org/maven2
)
)
end
Expand All @@ -98,6 +131,7 @@
https://kotlin.bintray.com/kotlinx
https://kotlin.bintray.com/ktor
https://kotlin.bintray.com/kotlin-dev/
https://repo.maven.apache.org/maven2
)
)
end
Expand All @@ -111,6 +145,7 @@
%w(
https://jcenter.bintray.com
https://hub.spigotmc.org/nexus/content/repositories/snapshots
https://repo.maven.apache.org/maven2
)
)
end
Expand All @@ -126,6 +161,7 @@
https://dl.bintray.com/magnusja/maven
https://kotlin.bintray.com/kotlinx
https://maven.google.com
https://repo.maven.apache.org/maven2
)
)
end
Expand Down
19 changes: 19 additions & 0 deletions gradle/spec/fixtures/buildfiles/maven_central_only.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
maven { url 'https://repo.maven.apache.org/maven2' }
}
}
19 changes: 19 additions & 0 deletions gradle/spec/fixtures/buildfiles/private_only_repos_build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
maven { url 'https://nexus.noyoucanthaveaccess.net/repository/maven/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
maven { url 'https://nexus.noyoucanthaveaccess.net/repository/maven/' }
}
}

0 comments on commit a7787cb

Please sign in to comment.