45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
const { withProjectBuildGradle, withSettingsGradle } = require('@expo/config-plugins');
|
|
|
|
const withSettingsRepositories = (config) => {
|
|
// 1. Modify settings.gradle (settings-level repositories)
|
|
config = withSettingsGradle(config, (config) => {
|
|
let contents = config.modResults.contents;
|
|
const reposBlock = `
|
|
// Added by withSettingsRepositories plugin
|
|
dependencyResolutionManagement {
|
|
repositories {
|
|
maven { url 'https://jitpack.io' }
|
|
maven { url 'https://jcenter.bintray.com' }
|
|
}
|
|
}
|
|
`;
|
|
if (!contents.includes('https://jcenter.bintray.com')) {
|
|
contents += reposBlock;
|
|
}
|
|
config.modResults.contents = contents;
|
|
return config;
|
|
});
|
|
|
|
// 2. Modify root build.gradle (project-level repositories)
|
|
config = withProjectBuildGradle(config, (config) => {
|
|
let contents = config.modResults.contents;
|
|
|
|
// Inject jcenter and jitpack into the allprojects.repositories block
|
|
if (!contents.includes('https://jcenter.bintray.com')) {
|
|
contents = contents.replace(
|
|
/maven\s*\{\s*url\s*['"]https:\/\/www\.jitpack\.io['"]\s*\}/g,
|
|
`maven { url 'https://www.jitpack.io' }
|
|
maven { url 'https://jcenter.bintray.com' }
|
|
maven { url 'https://jitpack.io' }`
|
|
);
|
|
}
|
|
|
|
config.modResults.contents = contents;
|
|
return config;
|
|
});
|
|
|
|
return config;
|
|
};
|
|
|
|
module.exports = withSettingsRepositories;
|