You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Dario Telese (JIRA)" <ji...@apache.org> on 2019/06/17 15:37:00 UTC

[jira] [Comment Edited] (CB-9704) Apache Cordova 5 does not support using a custom nexus repository for android builds

    [ https://issues.apache.org/jira/browse/CB-9704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16865553#comment-16865553 ] 

Dario Telese edited comment on CB-9704 at 6/17/19 3:36 PM:
-----------------------------------------------------------

 
{code:java}
// code placeholder
{code}
Hello,

 

this solution is great!! 

Look:
  [https://stackoverflow.com/questions/51934907/gradlew-change-jcenter-url-for-react-native-build]

 
 In .gradle Jenkins directory, create *init.gradle* file and insert this code:

 

 
{code:java}
apply plugin: EnterpriseRepositoryPlugin


class EnterpriseRepositoryPlugin implements Plugin<Gradle> {


private static String NEXUS_REPO = "https://mynexus/repository/mymavenrepo/"
private static String GOOGLE_REPOSITORY_URL = "https://dl.google.com/dl/android/maven2/"
private static String JCENTER_REPOSITORY_URL = "https://jcenter.bintray.com/"
private static String MAVEN_REPOSITORY_URL = "https://repo.maven.apache.org/maven2/"


void apply(Gradle gradle) {
// ONLY USE NEXUS REPO FOR DEPENDENCIES
gradle.allprojects { project ->
project.repositories {
// Remove all repositories not pointing to the NEXUS repository url
all { ArtifactRepository repo ->
if ((repo instanceof MavenArtifactRepository)){
if ((repo.url.toString() == GOOGLE_REPOSITORY_URL) || (repo.url.toString() == JCENTER_REPOSITORY_URL) || (repo.url.toString() == MAVEN_REPOSITORY_URL) ) {
project.logger.lifecycle "Repository ${repo.name} removed. Only NEXUS REPOSITORY is allowed"
remove repo
}
}
}
// add the NEXUS repository
maven {
name "NEXUS_REPO"
url NEXUS_REPO
}
}
}
}
}
{code}
 

Customize for your case and enjoy!!

Bye

 

 

 


was (Author: dario.telese):
Hello,

have you find a solution?

 

> Apache Cordova 5 does not support using a custom nexus repository for android builds
> ------------------------------------------------------------------------------------
>
>                 Key: CB-9704
>                 URL: https://issues.apache.org/jira/browse/CB-9704
>             Project: Apache Cordova
>          Issue Type: New Feature
>          Components: Ionic
>            Reporter: Ajay Gupta
>            Priority: Major
>
> We are using AngularJS and Ionic for writing a mobile application supported both on IOS and Android.  When we do "ionic build android --release", it creates a build.gradle file in both platforms/android directory and platforms/android/CordovaLib directory.  Both of these files point to mavenCentral() as the repository which tries to download artifacts directly from the maven central repo (http://repo1.maven.org/maven2).  We are trying to build our mobile apps as part of a Jenkins build behind company proxy and would like to have gradle reach out to our internal Maven nexus repository instead of reaching out to the central maven repository directly.  Our internal Neux repository would then proxy everything to the maven central repository.  
> We cannot hand edit the build.gradle file as it is a generated file and so any custom changes made to it would be lost in the next build.  Cordova 5 supports adding custom extensions using build-extras.gradle file but it does not support overriding repositories.  
> As a workaround, we have defined a pre-build Cordova hook to search replace mavenCentral() references to our local maven repository before doing an android build.  It works but is a unnecessary workaround and not a very clean solution.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org