Maven2Gradle


(Raphael C. Okere) #1

gradle.build and init.gradle configurations?

I want to build locally instead of using a repository so should my code look like below? (NOOB TO CODING)

gradle.build repositories{

mavenCentral() }

task showRepositories << {

repositories.each{

println “repository: $init.gradle (’$C:\gradle-1.10\DB_Support_v.1.05.00.01’)”

} }

init.gradle (wanted to convert from maven to gradle so was wondering if i was on the right track) (also put init.gradle in project folder)

import org.gradle.api.artifacts.repositories.ArtifactRepository import org.gradle.api.artifacts.repositories.MavenArtifactRepository

apply plugin:EnterpriseRepositoryPlugin

class EnterpriseRepositoryPlugin implements Plugin {

private static String ENTERPRISE_REPOSITORY_URL = “http://repo.gradle.org/gradle/repo

void apply(Gradle gradle) {

// ONLY USE ENTERPRISE REPO FOR DEPENDENCIES

gradle.allprojects{ project ->

project.repositories {

//remove all repositories not pointing to the enterprise repository url

all { ArtifactRepository repo ->

if (!(repo instanceof MavenArtifactRepository) || repo.url.toString() != ENTERPRISE_REPOSITORY_URL) {

project.logger.lifecycle “Repository ${repo.url} removed. Only $ENTERPRISE_REPOSITORY_URL is allowed”

remove repo

}

}

// add the enterprise repository

maven {

name “STANDARD_ENTERPRISE_REPO”

url ENTERPRISE_REPOSITORY_URL

}

}

}

} }


(René Groeschke) #2

Do I understand you correctly, that you want to resolve your dependencies from a local maven repository instead of hitting mavencentral? you can reconfigure your repositories definition to point to a local directory like this

repositories{
     maven{
         url = "file://local/repository"
     }
 }

The maven2gradle task does not generate any init.gradle file for you. I guess you got that snippet from a talk done by luke a while ago. This init.gradle file does remove all maven repositories that are not pointing to mavencentral.

cheers, René


(Raphael C. Okere) #3

Can you please email me? I could really use your help? raphaelokere@hotmail.com. I can send you some files to look at and you tell me where I am going wrong? I can pay you too!


(Raphael C. Okere) #4

How would a gradle.script code converted from the maven script below look:

<project xmlns=“http://maven.apache.org/POM/4.0.0

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

Core

pom

com.gpc.tamsii

DBSupportTool

1.00.00.00-SNAPSHOT

Verification and Platform jar code

http://www.genpt.com

Verification

Platform

commons-logging

commons-logging

1.0.4

javax

j2ee

1.0

log4j

log4j

1.2.8

poi

poi

2.5.1-final-20040804

com.sybase

jconn3

6.0

xerces

xerces

1.4.4

xmlwriter

xmlwriter

2.2

com.jcraft

jsch

0.1.39

javax.mail

mail

1.4.1

javax.activation

activation

1.1.1