PayBas opened a new issue #1165:
URL: https://github.com/apache/cordova-android/issues/1165
# Bug Report
## Problem
Since cordova-android `9.0.0` it is impossible for us to build our projects
without having to edit the output of the `cordova create` stage. This is due to
newly introduced dependencies in the `CordovaLib/cordova.gradle` script plugin,
which cannot be overwritten using regular means (such as an `init.gradle`
script). This means that dependency resolution will _always_ default to
`jcenter()`, which requires an internet connection, which we don't have for
good reason.
### What is expected to happen?
`cordova build` should be possible without an open internet connection.
### What does actually happen?
```
FAILURE: Build failed with an exception.
* Where:
Build file
'/home/jenkins/workspace/master-b21920/frontend/dist/mobile/platforms/android/app/build.gradle'
line: 28
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all artifacts for configuration 'classpath'.
> Could not resolve com.g00fy2:versioncompare:1.3.4.
Required by:
unspecified:unspecified:unspecified
> Could not resolve com.g00fy2:versioncompare:1.3.4.
> Could not get resource
'https://jcenter.bintray.com/com/g00fy2/versioncompare/1.3.4/versioncompare-1.3.4.pom'.
> Could not GET
'https://jcenter.bintray.com/com/g00fy2/versioncompare/1.3.4/versioncompare-1.3.4.pom'.
> jcenter.bintray.com: Name or service not known
```
## Information
The `CordovaLib/cordova.gradle` script plugin is called here:
https://github.com/apache/cordova-android/blob/9.0.0/bin/templates/project/app/build.gradle#L28
Since cordova-android `9.0.0` this script plugin contains newly introduced
dependencies (and repository definitions). See
https://github.com/apache/cordova-android/blob/9.0.0/framework/cordova.gradle#L197-L205
I'm not a Gralde expert, but after about 2 days of reading and
experimenting, I am convinced that "script plugins" do _not_ receive the same
treatment as projects. They can _not_ be affected by regular means (from an
`init.gradle` script for instance), such as:
```
allprojects {
buildscript.repositories ...
repositories ...
}
```
Probably related to:
- https://github.com/gradle/gradle/issues/1038
-
https://discuss.gradle.org/t/gradle-properties-are-not-available-when-applying-external-script-in-buildscript/8678
-
https://stackoverflow.com/questions/37285413/how-can-the-gradle-plugin-repository-be-changed#comment100408703_53269116
We rely on this _heavily_, due to our workstations and build-servers _not_
having any direct internet-connections.
To give you some idea. This is the `/home/jenkins/.gradle/init.gradle` file
we use on our build servers:
```
apply plugin: CorpGradleRepositoryPlugin
class CorpGradleRepositoryPlugin implements Plugin<Gradle> {
final Closure RemoveUnapprovedRepos = { thing ->
// Remove all repositories not pointing to *.internal.corp urls
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository
&& !repo.url.toString().contains("internal.corp")
&& !repo.url.toString().contains("m2repository")) {
remove repo
}
}
}
final Closure ApprovedRepos = {
maven {
url "https://nexus.internal.corp/nexus/repository/maven-public"
}
jcenter {
url "https://nexus.internal.corp/nexus/repository/jcenter"
}
}
void apply(Gradle gradle) {
gradle.allprojects { project ->
project.buildscript.repositories RemoveUnapprovedRepos
project.buildscript.repositories ApprovedRepos
project.repositories RemoveUnapprovedRepos
project.repositories ApprovedRepos
}
gradle.settingsEvaluated { settings ->
settings.pluginManagement {
repositories RemoveUnapprovedRepos
repositories ApprovedRepos
}
}
}
}
```
### Command or Code
`cordova build` + but using your own repositories + no internet = fail
### Environment, Platform, Device
Fedora 33, RHEL 8 and MacOS
### Version information
Cordova CLI 9.0.0
Cordova Android 9.0.0
Android SDK 29
## Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]