forked from m0smith/malabar-mode-jar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
m0smithgh-18 start support for gradle
- Loading branch information
Matthew O. Smith
committed
Apr 17, 2015
1 parent
12d7e4c
commit a4ec9c3
Showing
6 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/groovy/com/software_ninja/malabar/project/GradleProjectsCreator.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() ] | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/groovy/com/software_ninja/malabar/project/TestGradleProjectsCreator.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("", "."); | ||
|
||
} | ||
|
||
} |