Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3236 - Adding Maven Central fallback for gradle #3241

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
(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/' }
}
}