Skip to content

Commit

Permalink
gh-18 start support for gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew O. Smith committed Apr 17, 2015
1 parent 12d7e4c commit a4ec9c3
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
11 changes: 3 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()

}
Expand All @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,10 @@
<version>2.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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() ]

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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("", ".");

}

}

0 comments on commit a4ec9c3

Please sign in to comment.