Skip to content

Commit

Permalink
Added .project generation feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksoichiro committed Feb 21, 2015
1 parent 84e1e65 commit 2c84646
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class GenerateTask extends BaseTask {
generateEclipseProjectFile(p, d)
}
generateEclipseClasspathFileForParent(p)
generateEclipseProjectFileForParent(p)
generateProjectPropertiesFileForParent(p)
}
}
Expand Down Expand Up @@ -408,7 +409,6 @@ android.library=true
\t\t</buildCommand>
\t</buildSpec>
\t<natures>
\t\t<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
\t\t<nature>org.eclipse.jdt.core.javanature</nature>
\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
\t</natures>
Expand Down Expand Up @@ -477,6 +477,48 @@ android.library=true
}
}

void generateEclipseProjectFileForParent(Project p) {
def file = p.file(".project")
if (file.exists()) {
return
}
file.text = """\
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
\t<name>${p.name}</name>
\t<comment></comment>
\t<projects>
\t</projects>
\t<buildSpec>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t</buildSpec>
\t<natures>
\t\t<nature>org.eclipse.jdt.core.javanature</nature>
\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
\t</natures>
</projectDescription>
"""
}

void generateProjectPropertiesFileForParent(Project p) {
def projectPropertiesFile = p.file('project.properties')
List<String> libNames = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class SingleProjectSpec extends BaseSpec {

def "normalProject"() {
setup:
Project project = ProjectBuilder.builder().withProjectDir(new File("src/test/projects/normal")).build()
['.gradle', 'userHome', 'aarDependencies', 'libs', '.classpath', 'project.properties'].each {
Project project = ProjectBuilder.builder().withProjectDir(new File("src/test/projects/normal")).withName('normal').build()
['.gradle', 'userHome', 'aarDependencies', 'libs', '.classpath', '.project', 'project.properties'].each {
if (project.file(it).exists()) {
project.delete(it)
}
Expand All @@ -50,6 +50,7 @@ class SingleProjectSpec extends BaseSpec {
when:
project.tasks.generateEclipseDependencies.execute()
File classpathFile = project.file('.classpath')
File projectFile = project.file('.project')
File projectPropertiesFile = project.file('project.properties')

then:
Expand All @@ -70,6 +71,41 @@ class SingleProjectSpec extends BaseSpec {
\t<classpathentry kind="lib" path="libs/com.android.support-support-v4-21.0.2.jar"/>
\t<classpathentry kind="lib" path="libs/com.android.support-recyclerview-v7-21.0.0.jar"/>
</classpath>
"""
projectFile.exists()
projectFile.text == """<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
\t<name>${project.name}</name>
\t<comment></comment>
\t<projects>
\t</projects>
\t<buildSpec>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t</buildSpec>
\t<natures>
\t\t<nature>org.eclipse.jdt.core.javanature</nature>
\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
\t</natures>
</projectDescription>
"""
projectPropertiesFile.exists()
projectPropertiesFile.text == """target=android-21
Expand Down Expand Up @@ -113,6 +149,41 @@ android.library.reference.5=aarDependencies/com.android.support-recyclerview-v7-
\t<classpathentry kind="output" path="bin/classes"/>
\t<classpathentry kind="lib" path="libs/com.nineoldandroids-library-2.4.0.jar"/>
</classpath>
"""
File projectFile = project.file('.project')
projectFile.text = """<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
\t<name>${project.name}</name>
\t<comment></comment>
\t<projects>
\t</projects>
\t<buildSpec>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t</buildSpec>
\t<natures>
\t\t<nature>org.eclipse.jdt.core.javanature</nature>
\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
\t</natures>
</projectDescription>
"""
File projectPropertiesFile = project.file('project.properties')
projectPropertiesFile.text = """\
Expand Down Expand Up @@ -141,6 +212,41 @@ android.library.reference.1=aarDependencies/com.android.support-appcompat-v7-21.
\t<classpathentry kind="lib" path="libs/com.android.support-support-v4-21.0.2.jar"/>
\t<classpathentry kind="lib" path="libs/com.android.support-recyclerview-v7-21.0.0.jar"/>
</classpath>
"""
projectFile.exists()
projectFile.text == """<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
\t<name>${project.name}</name>
\t<comment></comment>
\t<projects>
\t</projects>
\t<buildSpec>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t\t<buildCommand>
\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t</buildSpec>
\t<natures>
\t\t<nature>org.eclipse.jdt.core.javanature</nature>
\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
\t</natures>
</projectDescription>
"""
projectPropertiesFile.exists()
projectPropertiesFile.text == """target=android-21
Expand Down
1 change: 1 addition & 0 deletions src/test/projects/multi/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ aarDependencies/
libs/
userHome/
.classpath
.project
project.properties
1 change: 1 addition & 0 deletions src/test/projects/normal/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ aarDependencies/
libs/
userHome/
.classpath
.project
project.properties
1 change: 1 addition & 0 deletions src/test/projects/version/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ aarDependencies/
libs/
userHome/
.classpath
.project
project.properties

0 comments on commit 2c84646

Please sign in to comment.