Results 1 to 5 of 5

Thread: gradle-eclipse: "No project name mapping was defined for project" on import

  1. #1
    Join Date
    May 2009
    Posts
    12

    Default gradle-eclipse: "No project name mapping was defined for project" on import

    Hi all,

    We have converted some of our large multi module Maven projects over to Gradle. These projects build perfectly when using Gradle from a shell however when I try and import them in to STS (3.2.0.M1 using GradleIDE 3.2.0.201211290814-M1) as a Gradle Project I receive the following error:

    "No project name mapping was defined for project :<project-name>"

    I initially thought this might be an error in the settings.xml but all the projects for which I get this error are mentioned in this file. As such I'm unsure how to progress my debugging of this issue. Does anyone know what might cause this? The error appears deterministically (i.e. always for the same projects) and does not affect all projects (i.e some import just fine)

    I'm trying to create a small reproducable example that I can share but so-far have had no luck in being able to reproduce the problem in the new project. Will attach the project as soon as I can reproduce.

    Many thanks.

  2. #2
    Join Date
    May 2010
    Posts
    412

    Default

    The error is likely from STS gradle tooling and most likely a bug in the tooling. I think this is where it is coming from:

    https://github.com/SpringSource/ecli...pper.java#L121

    The name mapping referred to here is some computed gradle to Eclipse project name map that is used while importing a Gradle project. All imported projects should get a 'name mapping' automatically computed by the tools.

    Essentially the mapping defines what a gradle project will be called in the Eclipse workspace.

    I would need to be able to reproduce the problem and look around with a debugger to try and see what is causing this.

    One thing you can do is take a look in the Eclipse error log (Window >> show view >> Error log) maybe some other errors got logged there that give clues on what went wrong.

    For accuracy... clear the error log first. Then do whatever it is you do to cause the error, then see if something interesting / new appears in the log at the same time.

    Kris

    PS: One thing comes to mind maybe you have some upper/lower case confusion in project names. That might explain that a name mapping is not being found because its spelled upper/lower in one place and differently another. I've seen weirdness like that happen when people have case-insensitive file systems such as on Mac OS. They have project called 'foobar' and on the file system its directory is called 'fooBar'. The OS considers these the same, but the tools won't. The confusion can cause strange errors / bugs to manifest.
    Kris De Volder -- SpringSource

  3. #3
    Join Date
    May 2009
    Posts
    12

    Default

    Hi Kris,

    Thanks for replying. The stacktrace I get from the error log is:

    java.lang.IllegalArgumentException: No project name mapping was defined for project ':EM3SystemTest/Automation_WorkItems/em3-data-creation-suite'
    at org.eclipse.core.runtime.Assert.isLegal(Assert.jav a:63)
    at org.springsource.ide.eclipse.gradle.core.wizards.P recomputedProjectMapper.get(PrecomputedProjectMapp er.java:121)
    at org.springsource.ide.eclipse.gradle.core.wizards.G radleImportOperation$MissingProjectDependencyExcep tion.<init>(GradleImportOperation.java:398)
    at org.springsource.ide.eclipse.gradle.core.wizards.G radleImportOperation.verify(GradleImportOperation. java:449)
    at org.springsource.ide.eclipse.gradle.core.wizards.G radleImportOperation.verify(GradleImportOperation. java:424)
    at org.springsource.ide.eclipse.gradle.ui.wizards.Gra dleImportWizardPageOne.checkPageComplete(GradleImp ortWizardPageOne.java:359)
    at org.springsource.ide.eclipse.gradle.ui.wizards.Gra dleImportWizardPageOne$1.checkStateChanged(GradleI mportWizar
    dPageOne.java:169)


    As you can see the name of the project being depended upon contains upper and lower case characters, as well as hyphens and underscores (bonkers naming convention I know - I will be fixing this!). I checked all references to the project (from build.gradle, settings.gradle etc) and they all seem to be perfectly typed. I also renamed the project path, stripping out all the hyphens and underscores and lower casing the text. I then updated all references to the project and re-tried the import but unfortunately the problem occurs in exactly the same way with the same stack trace (albeit with the updated project name).

    The project dependency is declared in our build.gradle as follows:

    testCompile project(":EM3SystemTest/Automation_WorkItems/em3-data-creation-suite")


    Could it be that the STS tooling isn't coping with this declaration somehow? Grateful for any further ideas you may have or for anything I can do to provide further info.

    Cheers,

    Edd

  4. #4
    Join Date
    May 2010
    Posts
    412

    Default

    Not sure the testCompile dependency has anything to do with it. It is possible, but Idoubdt it. If you suspect it might, you can try commenting it out and doing the import again. Missing dependencies like that shouldn't cause the import to fail though you might end-up with an incomplete classpath for your project(s) after import, causing compile errors in the workspace.

    What seems most likely at this point to me, given where the error is coming from is that its some weirdness caused by names with funny characters.

    Not sure how to diagnose it. If I could reproduce it and poke around with a debugger I could probably figure out what's going wrong. But you say you weren't able to reproduce it in a sample project.

    One thing we can try is add more info to that error message (e.g. dump the entire contents of computed name mapping in it, maybe it will reveal something interesting about the suspected name 'funnyness').

    This will require you to update to a snapshot build of gradle tools and then when you get the error again, we may get a bit more info.

    I'll post something here when I got something for you to try later.

    Kris
    Kris De Volder -- SpringSource

  5. #5
    Join Date
    May 2010
    Posts
    412

    Default

    I just pushed a change to add more info to that error message. You can update your gradle tooling from this update site:

    http://dist.springsource.com/snapsho...gradle/nightly

    Error should then dump out the contents of the map as well as the value of the key that was used to look up.
    Somehow there's a mismatch between these two and hopefully the message will help figure out why exactly.

    Kris
    Kris De Volder -- SpringSource

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •