2

I am new to gradle and trying to use the gradle plugin in eclipse.

Created a java gwt project using an online project generator https://gwt-project-generator.cfapps.io/

enter image description here

It imported all the dependencies very nicely.

Now I am trying to rename the project from demo to gradle-demo and I am confused. It automatically reverts the name to demo each time. In the build.gradle file I see nothing that would indicate enforcement of the name.

Any pointers ?

    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
    }
}

apply plugin: 'gwt'
apply plugin: 'war'

// In this section you declare where to find the dependencies of your project
repositories {
    jcenter()
}

repositories { mavenCentral() }

// In this section you declare the dependencies for your production and test code
dependencies {
    providedCompile('fr.lteconsulting:angular2-gwt:1.6')
    providedCompile('com.google.dagger:dagger-gwt:2.8')
    providedCompile('org.jboss.gwt.elemento:elemento-core:0.5')
    providedCompile('com.vaadin.polymer:vaadin-gwt-polymer-elements:1.7.0.0')
    providedCompile('org.gwtbootstrap3:gwtbootstrap3:0.9.3')
    providedCompile('com.github.tdesjardins:gwt-ol3:2.9.0')
    providedCompile('com.googlecode.gwtquery:gwtquery:2.1.0')
    providedCompile('com.github.gwtreact:gwt-react:0.3.0')
    providedCompile('com.gwidgets:gwty-leaflet:0.4')
    providedCompile('com.sksamuel.jqm4gwt:jqm4gwt-remote:2.1.0')
    providedCompile('com.intendia.gwt:rxjava-gwt:1.0.14-beta1')
    testCompile('junit:junit:4.11')
    testCompile('com.google.gwt.gwtmockito:gwtmockito:1.1.6')

}

gwt {
    gwtVersion='2.8.0'

    modules 'com.ainosoft.firstGradleGwt'

    maxHeapSize = "1024M"

    superDev {
        noPrecompile=true
    }
}

It also shows missing builder in project configuration for gwt enter image description here

Gautam
  • 1,030
  • 13
  • 37
  • Have a look https://stackoverflow.com/q/11530420/7403180 – sForSujit Aug 21 '17 at 09:12
  • next time do some investigation, please, [this](https://discuss.gradle.org/t/renaming-eclipse-project-names-and-eclipse-wtp/6757) is the 1st link in google. and [this](https://docs.gradle.org/3.3/dsl/org.gradle.plugins.ide.eclipse.model.EclipseProject.html) is the second one from the Gradle docs itself. – LazerBanana Aug 21 '17 at 10:24
  • 1
    @LazerBanana thanks for pointing out but as you will notice this question is not on SO and I think its a valid approach to ask a question that's not present here. Obviously a large number of issues are addressed on the web but I use SO as my first stop to code / project QA. Not going to google or not reading the docs in entirety shouldn't prohibit me from asking a relevant question here. Having used eclipse since inception I would assume refactor > rename to work without hassles. I think SO encourages such discussions to help the community members. Don't you think ? – Gautam Aug 21 '17 at 10:43
  • I'm not going to express my personal opinion here as this is not the place to debate. The rule is: Do the research, show effort, then ask. The main problem on SO is that people ask everything without any effort. If you would find the solution you would not ask the question, same with everyone else. Maybe you should read [[How to ask a good question](https://stackoverflow.com/help/how-to-ask)] – LazerBanana Aug 21 '17 at 10:48
  • nowhere it suggests you google it first. I came to SO and searched and no matching questions. And since I imported a basic gradle project to start with and I am using eclipse gradle plugin I expect the refactor to work as expected. So I still see my question as a valid question. – Gautam Aug 21 '17 at 11:03

3 Answers3

15

Add this to your build.gradle

apply plugin: 'eclipse'
eclipse {
    project {
        name = 'some-better-name'
    }
}

See EclipseProject docs

lance-java
  • 25,497
  • 4
  • 59
  • 101
  • applying the eclipse plugin causes my tests to give a weird compilation error where it doesn't find the GWTTestCase base class anymore. It did rename the project now successfully though but the tests were successfully compiling before and now they have compilation error. – Gautam Aug 21 '17 at 09:24
  • I'm guessing you've manually added things to `.project` and `.classpath` (eg natures etc) which are being overridden when gradle generates the `.project` and `.classpath`. If you want customisations in your `.project` and `.classpath` you'll need to do this in the [eclipse plugin](https://docs.gradle.org/current/userguide/eclipse_plugin.html#sec:eclipse_configuration) – lance-java Aug 21 '17 at 09:50
  • none.. and there is no reason to assume such. also the plugin in question is not eclipse but eclipse-wtp as I read in the docs and other SO discussions. It still refuses to find my GWTTestCase class so I am assuming I will need to add a specific gwt jar explicitly.. – Gautam Aug 21 '17 at 10:32
  • You'll need to declare all jar dependencies in `build.gradle`. Do your tests compile from gradle command line? – lance-java Aug 21 '17 at 10:57
  • no.. but I found the issue. I had to change one of the dependencies and it fixed the problem. – Gautam Aug 21 '17 at 10:58
  • haha... ok... well if it ain't compiling from command line, it ain't gonna compile in eclipse either :D – lance-java Aug 21 '17 at 11:18
3

Eclipse's Refactor->Rename... seems not to work perfectly with Gradle projects.

  • Open settings.gradle and modify rootProject.name accordingly.

    For example:

    rootProject.name = 'coolproject'
    

    Make sure this is in settings.gradle, not build.gradle!

  • Right click the project and click Gradle->Refresh Gradle Project

nathanfranke
  • 775
  • 1
  • 9
  • 19
0

To rename a Gradle project in eclipse.

1)Right click on project -> Refactor -> Rename ->Type the new name and tick update references and click ok

2)Open settings.gradle and modify rootProject.name accordingly.And save it

For example:

rootProject.name = 'coolproject'

3)Right click the project and click Gradle->Refresh Gradle Project.

4)After this also it shows error , then close eclipse and reopen again.