Nodeclipse / nodeclipse

Nodeclipse-1 : Eclipse plugin for Node.js, PhantomJS development (Nodeclipse core plugin); Maven and Gradle (with Android) plugins
https://nodeclipse.github.io/
158 stars 76 forks source link

Eclipse cannot import gradle built project or cannot convert project to using gradle #167

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hello,

I use Eclipse 4.4 with

Gradle IDE Pack 3.6.x, 0.17 Nodeclipse/Enide Gradle for Eclipse 0.17 Minimalist Gradle Editor 0.17

I have run into the following problems trying to import a gradle built android project into Eclipse and changing an android project in Eclipse to be built using Gradle: 1) File >>> Import >>> Existing Project into Workspace Right click on project just imported, click on Gradle, click on task quick launcher

The error message is:

org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 Could not fetch model of type 'EclipseProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.12-all.zip'.

The above error message is produced whenever a Gradle related operation is attempted.

2) File >>> Import >>> Gradle project Click on Build Model

The error message is:

org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 Could not fetch model of type 'EclipseProject' using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.0-bin.zip'.

Please let me know if you need additional information.

Thank you,

Alex Donnini

paulvi commented 10 years ago

Usually you would need to share .project , .classpath and build.gradle files

But as it is Android project, quick answer is:
No, Gradle build as primary is not supported in Eclipse, because Google has not yet updated gradle eclipse plugin and ADT toolings ( see SO),
Nodeclipse/Enide Gradle for Eclipse 0.17 however lets you have gradle build as secondary.

I would like to explore Android Gradle support further and need help with knowledge sharing and feedback. Please share mentioned files above.

ghost commented 10 years ago

Hello Paul, Thanks for your quick response.

How would you like me to send you the three files you asked for? Here I can only send you images. Should I simply respond to the email message? I'll try that

What do you mean by gradle build as secondary?

Thanks,

Alex Donnini

ghost commented 10 years ago

Hi Paul,

Please find attached an archive with all the files you requested and other files which I thought you might find useful.

Please let me know if you need anything else, or how I can help.

When you get a chance, please let me know what you mean by "gradle build as secondary".

Thanks,

Alex Donnini

Paul Verest wrote:

Usually you would need to share |.project , .classpath| and |build.gradle| files

But as it is Android project, quick answer is:

No, Gradle build as primary is not supported in Eclipse, because Google has not yet updated gradle eclipse plugin and ADT toolings,

however Nodeclipse/Enide Gradle for Eclipse 0.17 however lets you have gradle build as secondary.

I would like to explore Android Gradle support further and need help with knowledge sharing and feedback. Please share mentioned files above.

— Reply to this email directly or view it on GitHub https://github.com/Nodeclipse/nodeclipse-1/issues/167#issuecomment-57076227.

paulvi commented 10 years ago

Hi Alex

email you sent goes to GitHub robot, not me. And only text is added to issue.

Usually copy-paste file context inside "" and "" Read https://guides.github.com/features/mastering-markdown/ link that you have above every comment text area as "Parsed as Markdown "

for "gradle build as secondary" read SO link I gave above.

ghost commented 10 years ago

Hi Paul,

Thanks. I had already seen the SO entry you refer to. I did not realize that that is what you meant.

Below you will find the information you requested. Please let me know if you need anything else.

Thanks,

Alex

.project

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>my-beacon-library-test</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src/main/java"/>
    <classpathentry exported="true" kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="lib" 
path="/home/adonnini1/commmanager_libs/android-19/android.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

build.gradle

ext {
     SONATYPE_URL = ""
     IS_DEV_BUILD = false
     IS_RELEASE_BUILD = false
     GROUP = "org.altbeacon"
}

/*
  * Gets the version name from the latest Git tag
  */
def getVersionName = { ->
     def stdout = new ByteArrayOutputStream()
     try {
         exec {
             commandLine 'git', 'describe', '--tags'
             standardOutput = stdout
         }
         return stdout.toString().trim()
     }
     catch (e) {
         println("Can't get version from git: "+e);
         return "adhoc"
     }
}

version = getVersionName()
group = GROUP

if (hasProperty("release")) {
     IS_RELEASE_BUILD = true
     SONATYPE_URL = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else if (hasProperty("snapshot")) {
     version += "-SNAPSHOT"
     SONATYPE_URL = "https://oss.sonatype.org/content/repositories/snapshots/"
} else {
     IS_DEV_BUILD = true
}

buildscript {
     repositories {
         mavenCentral()
     }

     dependencies {
//        classpath 'com.android.tools.build:gradle:0.13'
         classpath 'com.android.tools.build:gradle:0.12.+'
         classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
         classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+'
     }
}

apply plugin: 'android-sdk-manager'
apply plugin: "android-library"
apply plugin: 'robolectric'

allprojects {
     repositories {
         mavenCentral()
         maven {
             url 'https://oss.sonatype.org/content/repositories/snapshots'
         }
     }
}

android {
     compileSdkVersion 19
     buildToolsVersion '19.1.0'

     compileOptions {
         encoding "UTF-8"
         sourceCompatibility JavaVersion.VERSION_1_7
         targetCompatibility JavaVersion.VERSION_1_7
     }

     defaultConfig {
         minSdkVersion 1
         targetSdkVersion 19
         versionName = version
         testInstrumentationRunner 
"com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
     }

     buildTypes {
         release {
             runProguard false
         }
     }

     sourceSets {
         androidTest {
             setRoot('src/test')
         }
     }

     lintOptions {
         abortOnError false
     }

     packagingOptions {
         exclude 'LICENSE.txt'
         exclude 'META-INF/LICENSE'
         exclude 'META-INF/LICENSE.txt'
         exclude 'META-INF/NOTICE'
     }

}

robolectric {
     include '**/*Test.class'
}

dependencies {
     androidTestCompile 'org.hamcrest:hamcrest-integration:1.3'
     androidTestCompile 'org.hamcrest:hamcrest-core:1.3'
     androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

     androidTestCompile('junit:junit:4.11') {
         exclude module: 'hamcrest-core'
     }
     androidTestCompile('org.robolectric:robolectric:2.3') {
         exclude module: 'classworlds'
         exclude module: 'commons-logging'
         exclude module: 'httpclient'
         exclude module: 'maven-artifact'
         exclude module: 'maven-artifact-manager'
         exclude module: 'maven-error-diagnostics'
         exclude module: 'maven-model'
         exclude module: 'maven-project'
         exclude module: 'maven-settings'
         exclude module: 'plexus-container-default'
         exclude module: 'plexus-interpolation'
         exclude module: 'plexus-utils'
         exclude module: 'wagon-file'
         exclude module: 'wagon-http-lightweight'
         exclude module: 'wagon-provider-api'
     }

     androidTestCompile 'com.squareup:fest-android:1.0.+'
}

apply plugin: 'idea'

idea {
     module {
         testOutputDir = file('build/test-classes/debug')
     }
}

apply plugin: "maven"
apply plugin: "signing"

afterEvaluate { project ->
     uploadArchives {
         repositories {
             if (IS_DEV_BUILD) {
                 mavenLocal()
             } else {
                 mavenDeployer {
                     beforeDeployment { MavenDeployment deployment -> 
signing.signPom(deployment) }

                     repository(url: SONATYPE_URL) {
                         authentication(userName: sonatypeUsername, password: 
sonatypePassword)
                     }

                     println GROUP

                     pom.project {
                         name 'Android Beacon Library'
                         packaging 'aar'
                         description 'Beacon library for Android applications'
                         artifactId = 'android-beacon-library'
                         groupId GROUP
                         version version
                         url 
'https://github.com/RadiusNetworks/android-beacon-library'

                         scm {
                             url 
'scm:git@github.com:RadiusNetworks/android-beacon-library.git'
                             connection 
'scm:git@github.com:RadiusNetworks/android-beacon-library.git'
                             developerConnection 
'scm:git@github.com:RadiusNetworks/android-beacon-library.git'
                         }

                         licenses {
                             license {
                                 name 'The Apache Software License, Version 2.0'
                                 url 
'http://www.apache.org/licenses/LICENSE-2.0.txt'
                                 distribution 'repo'
                             }
                         }

                         developers {
                             developer {
                                 id 'davidgyoung'
                                 name 'David Young'
                                 email 'david@radiusnetworks.com'
                             }
                         }
                     }

                 }
             }
         }
     }

     signing {
         required { IS_RELEASE_BUILD && gradle.taskGraph.hasTask("uploadArchives") }
         sign configurations.archives
     }

     task androidJavadocs(type: Javadoc) {
         source = android.sourceSets.main.java
     }

     task androidJavadocsJar(type: Jar) {
         classifier = 'javadoc'
         from androidJavadocs.destinationDir
     }

     task androidSourcesJar(type: Jar) {
         classifier = 'sources'
         from android.sourceSets.main.java.srcDirs
     }

     artifacts {
         archives androidSourcesJar
         archives androidJavadocsJar
     }
}

/** Bundling tasks for eclipse */
task bundleEclipse << {
     exec {
         executable 'scripts/bundle-eclipse'
     }
}

task distribution(dependsOn: ["bundleEclipse", "build", "clean"]) << {
     println "Building with version=$version"
}

task release(dependsOn: 'distribution') << {
     println('Doing release build')
}

build.mustRunAfter clean
bundleEclipse.mustRunAfter build
paulvi commented 10 years ago

The standard .files for Android project are below, you can get them by creating new project with Eclipse-ADT:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>app-name</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ApkBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

As you see your .project only references JDT, but not ADT (so any of your folder gets Android A).

Next because the project is not actually ADT project, some twuicks are needed:

  1. In .classpath say sources are in src/main/java

    <classpathentry kind="src" path="src/main/java"/>

  2. Next is to do using OS

On Lunix ln -s src/main/res res ln -s src/main/AndroidManifest.xml AndroidManifest.xml

On Windows I don't yet know grace way:
http://stackoverflow.com/questions/26081449/symbolic-links-on-windows

Now project is to be ready to be imported as existing project.

Note that Eclipse will continue to be using ADT to build.
While in the same time Gradle can be launch by right-clicking on build.gralde to build and and run.

By default it is run with --daemon switch, so first time it is longer, then much quicker.

Next please read http://www.nodeclipse.org/projects/gradle/

Possibly there are other ways of Eclipse configuration that I don't know (e.g. how to configure Gradle Integration for Eclipse, but it is definitely not with gradle eclipse as mentions in SO link

The eclipse plugin is not compatible with the android plugin.

I am exploring of ways to use Gradle conveniently in Eclipse, and use Eclipse and Android Studio togethertogether. )

ghost commented 10 years ago

Thank you very much Paul. I will follow your instructions. I hope you won't mind if I contact you again if I have any questions.

Please let me know if at any time you would like me to test something. I am very interested in having a working Eclipse-gradle solution.

Thanks,

Alex Donnini

Paul Verest wrote:

The standard .files for Android project are below, you can get them by creating new project with Eclipse-ADT:

  • |.project| :

|<?xml version="1.0" encoding="UTF-8"?>

app-name com.android.ide.eclipse.adt.ResourceManagerBuilder com.android.ide.eclipse.adt.PreCompilerBuilder org.eclipse.jdt.core.javabuilder com.android.ide.eclipse.adt.ApkBuilder com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature

|

  • |.classpath| :

|<?xml version="1.0" encoding="UTF-8"?>

|

As you see your .project only references JDT, but not ADT (so any of your folder gets Android A).

Next because the project is not actually ADT project, some twuicks are needed:

1.

In .classpath say sources are in src/main/java

2.

Next is to do using OS

On Lunix ln -s src/main/res res ln -s src/main/AndroidManifest.xml AndroidManifest.xml

On Windows I don't yet know grace way:

http://stackoverflow.com/questions/26081449/symbolic-links-on-windows

Now project is to be ready to be imported as existing project.

Note that Eclipse will continue to be using ADT to build.

While in the same time Gradle can be launch by right-clicking on |build.gralde| to build and and run.

By default it is run with |--daemon| switch, so first time it is longer, then much quicker.

Next please read http://www.nodeclipse.org/projects/gradle/

  • Design differences
  • Using together

Possibly there are other ways of Eclipse configuration that I don't know (e.g. how to configure Gradle Integration for Eclipse, but it is definitely not with |gragle eclipse| as mentions in SO ink

The eclipse plugin is not compatible with the android plugin.

I am exploring of ways to use Gradle conveniently in Eclipse, and use Eclipse and Android Studio togethertogether. )

— Reply to this email directly or view it on GitHub https://github.com/Nodeclipse/nodeclipse-1/issues/167#issuecomment-57110650.

paulvi commented 10 years ago

@adonnini I have posted as article at http://www.nodeclipse.org/projects/gradle/#Importing-from-Android-Studio-into-Eclipse

paulvi commented 10 years ago

by the way, can we consider original question closed? raise new issue when there are new aspects.

Please let me know if at any time you would like me to test something.

Please help me to research on following:

Please raise new issue and reference #167 if you have something to add or to ask.

ghost commented 10 years ago

Certainly. Thanks. Have a good day,

Alex

Paul Verest wrote:

by the way, can we consider original question closed? raise new issue when there are new aspects.

Please let me know if at any time you would like me to test something.

Please help me to research on following:

Please raise new issue and reference #167 https://github.com/Nodeclipse/nodeclipse-1/issues/167 if you have something to add or to ask.

— Reply to this email directly or view it on GitHub https://github.com/Nodeclipse/nodeclipse-1/issues/167#issuecomment-57116703.

paulvi commented 10 years ago

is it possible to create symlinks using Eclipse

I have tried using Eclipse

inside .project add

<linkedResources>
    <link>
        <name>AndroidManifest.xml</name>
        <type>1</type>
        <locationURI>PROJECT_LOC/src/main/AndroidManifest.xml</locationURI>
    </link>
    <link>
        <name>res</name>
        <type>2</type>
        <locationURI>PROJECT_LOC/src/main/res</locationURI>
    </link>
</linkedResources>

while it looks OK in Eclipse, ADT can't work with such resource

[2014-09-30 17:09:08 - MyApplication081-mobile] ERROR: resource directory 'C:\Users\weibl\AndroidStudioProjects\MyApplication081\mobile\res' does not exist
[2014-09-30 17:11:35 - MyApplication081-mobile] AndroidManifest.xml file missing!
paulvi commented 10 years ago

closing as solved and silent

aaidan commented 8 years ago

You're right, I was selecting the root of the project directory (like you would in Eclipse), not the main project's directory. After selecting it, I did get the specialized wizard. Thanks! http://goo.gl/8aE6LK

paulvi commented 8 years ago

:+1: