diff --git a/build.gradle b/build.gradle index 432d4f9..3862837 100755 --- a/build.gradle +++ b/build.gradle @@ -12,13 +12,8 @@ version version mainClassName = "com.software_ninja.malabar.Malabar" repositories { - maven { - url "http://repo.gradle.org/gradle/libs-releases-local" - } - - maven { - url "http://artifacts.co.ihc.com/repomgr/content/groups/combined/" - } + mavenLocal() + maven { url "http://repo.gradle.org/gradle/libs-releases-local" } mavenCentral() } @@ -42,7 +37,7 @@ dependencies { compile 'org.fusesource.jansi:jansi:1.11' compile 'junit:junit:4.11' compile 'org.slf4j:slf4j-jdk14:1.7.5' - compile "org.gradle:gradle-tooling-api:2.2.1" + compile "org.gradle:gradle-tooling-api:2.3" testCompile 'net.java.quickcheck:quickcheck:0.6' diff --git a/pom.xml b/pom.xml index 43991e8..dc4b0d1 100755 --- a/pom.xml +++ b/pom.xml @@ -92,5 +92,10 @@ 2.3.0 compile + + org.gradle + gradle-tooling-api + 2.2.1 + diff --git a/src/main/groovy/com/software_ninja/malabar/project/GradleProjectsCreator.groovy b/src/main/groovy/com/software_ninja/malabar/project/GradleProjectsCreator.groovy new file mode 100755 index 0000000..e0e7533 --- /dev/null +++ b/src/main/groovy/com/software_ninja/malabar/project/GradleProjectsCreator.groovy @@ -0,0 +1,43 @@ +package com.software_ninja.malabar.project; + +import org.gradle.tooling.model.idea.IdeaProject; +import org.gradle.tooling.model.idea.IdeaModule; +import org.gradle.tooling.GradleConnector; +//http://localhost:4429/pi/?pm=gradle&pmfile=c:/Users/lpmsmith/projects/malabar-mode-jar&repo=c:/Users/lpmsmith/.m2/repository + + +public class GradleProjectsCreator { + + + public create( String repo, String pmfile){ + def connection = GradleConnector.newConnector().forProjectDirectory(new File(pmfile)).useInstallation(new File("c:/Users/lpmsmith/.gradle/wrapper/dists/gradle-2.2.1-bin/88n1whbyjvxg3s40jzz5ur27/gradle-2.2.1")).connect(); + println " /// Connected" + def builder = connection.model(IdeaProject.class); + println " /// Made builder" + IdeaProject model = builder.get() + println " /// got model" + + return model.getModules(); + } + + public resolveDependencies( model, _repo, scope) { + def gradleScope = scope == 'runtime' ? 'COMPILE' : 'TEST'; + println model.getClass().getName(); + def deps0 = model.getDependencies(); + println deps0; + def deps = deps0.grep({ it.scope == gradleScope }); + println deps; + + [ dependencies : deps.gather{it.file.toString()}, + + resources: [] , + + sources: "test" == scope ? model.modules.contentRoots.testDirectories.gather({it.directory}) : + model.modules.contentRoots.sourceDirectories.gather({it.directory}), + + elements: "test" == scope ? model.compilerOutput.outputDir.toString() : + model.compilerOutput.testOutputDir.toString() ] + + } + +} diff --git a/src/main/groovy/com/software_ninja/malabar/project/MavenProjectHandler.groovy b/src/main/groovy/com/software_ninja/malabar/project/MavenProjectHandler.groovy index 2aa0144..26e4a7d 100755 --- a/src/main/groovy/com/software_ninja/malabar/project/MavenProjectHandler.groovy +++ b/src/main/groovy/com/software_ninja/malabar/project/MavenProjectHandler.groovy @@ -369,7 +369,7 @@ public class MavenProjectHandler { def repox = (repo == null ? "~/.m2/repository" : repo); try { - def x = new MavenProjectsCreator(); + def x = pm == "gradle" ? new GradleProjectsCreator() : new MavenProjectsCreator(); def pjs = x.create(MalabarUtil.expandFile(repox), MalabarUtil.expandFile(pmfile)) return [runtime: x.resolveDependencies(pjs[0], repox, "runtime"), systemProperties : System.getProperties(), diff --git a/src/main/groovy/com/software_ninja/malabar/project/MavenProjectsCreator.groovy b/src/main/groovy/com/software_ninja/malabar/project/MavenProjectsCreator.groovy index b2aaae9..1e2355f 100755 --- a/src/main/groovy/com/software_ninja/malabar/project/MavenProjectsCreator.groovy +++ b/src/main/groovy/com/software_ninja/malabar/project/MavenProjectsCreator.groovy @@ -18,7 +18,7 @@ import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.project.ProjectBuilder; - +import java.util.logging.Level; import org.codehaus.plexus.DefaultPlexusContainer; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.execution.MavenExecutionRequestPopulationException; diff --git a/src/test/groovy/com/software_ninja/malabar/project/TestGradleProjectsCreator.groovy b/src/test/groovy/com/software_ninja/malabar/project/TestGradleProjectsCreator.groovy new file mode 100755 index 0000000..0af9487 --- /dev/null +++ b/src/test/groovy/com/software_ninja/malabar/project/TestGradleProjectsCreator.groovy @@ -0,0 +1,18 @@ +package com.software_ninja.malabar.project; + +import org.junit.Test; +import org.junit.Before; + +import static org.junit.Assert.* + +public class TestGradleProjectsCreator { + GradleProjectsCreator target = new GradleProjectsCreator(); + + @Test + void testArgs(){ + println System.getProperty ('user.dir'); + target.create("", "."); + + } + +}