Gradle: "Refresh All" removes linked project in Java build Path - eclipse

I am using libgdx to make a ios game with RoboVM. I am using the latest versions of LibGDX, RoboVM and my Eclipse is up to date.
Recently I have been trying to add Google Analytics thanks to the Robovm bindings.
I have manually imported the analytics project in Eclipse:
with File -> Import -> Gradle project
Everyting works fine, I can import and use the classes in my ios project.
But then if I right click my ios project -> Gradle -> refresh all, the build is succesful but it removes the analytics project from the java build path. As a result, when I try to compile my ios project from a terminal with a command line, it doesn't compile since it doesn't fine the analytics classes. I am using "./gradlew -Probovm.device.name=myiPhone launchIOSDevice --stacktrace"
I guess there is a setting or property in Gradle or Robovm that I should change, anybody has an idea?

Answering to myself, it might help others... I ended up creating my own jar from the analytics project, and added it as a library in a separate folder. As described here: https://github.com/BlueRiverInteractive/robovm-ios-bindings/blob/master/README.md
This way every new Gradle build correctly links it to my ios project.

Related

Kotlin And Java In The Same Project Using Eclipse IDE

I posted a similar question regarding gradle but this question is without gradle or maven.
I can not get Kotlin working properly using Eclipse IDE. This works great using IntelliJ, however many developers still use Eclipse. I have installed the Kotlin Eclipse plugin and does not work. I have downloaded the Kotlin standard library and runtime library and added them into the project. Still not working. All I get in eclipse when I have Java and Kotlin is cannot be resolve to a specified type.
I'm not using maven or gradle because I couldn't get it working with those two either.
If I mix Java and Kotlin in the same source folder I get this error.
"The type error.NonExistentClass cannot be resolved. It is indirectly referenced from required .class files"
I'm using Eclipse Neon. If anyone can help me that would be awesome, I've been trying for quite some time now and not getting anywhere. :(
Add Kotlin Nature fixes the issue. Click on your project and Configure
Kotlin -> Add Kotlin nature
This partially fixes the issue, though eclipse plugin is still buggy and auto import function still doesn't work for me.
If you're having any issue, make sure you have kotlin_bin folder added in your project. Also make sure that ALL kotlin files have the correct package name sometimes when you rename packages or move files around kotlin classes may not get updated.
Got similar issue solved by adding a new Kotlin file to a Kotlin/Java mixed project. Adding the file caused Eclipse 2018-09 (4.9.0) to add kotlin-stdlib.jar and kotlin-reflect.jar to classpath and everything started working.
Add Kotlin Nature fixes the issue. Click on your project and Configure Kotlin -> Add Kotlin nature
As of the current Eclipse version (2019-09):
You can't add Kotlin to a Java project, but you can add Java to a Kotlin project.
The procedure to accomplish a mixed Kotlin/Java project was roughly:
Install Kotlin plug-in
Create empty Kotlin project
Move the Java code into the Kotlin project
Delete the original project
Fix project references
I'm working on a project with Spring Boot and Kotlin (some controllers/mappers/classes in Java and others in Kotlin) and after trying a lot of approaches, the only that worked was to use Eclipse 03-2020 and Kotlin Plugin for Eclipse V0.8.19.
https://dl.bintray.com/jetbrains/kotlin/eclipse-plugin/0.8.19/
Before everything, close your project and uninstall the previous version of Kotlin Plugin for Eclipse.
Go to Help/Install New Software.
Copy the link of Eclipse Plugin and continue with the installation (do not forget to check all the options to install).
After the installation restart the IDE and try compile again.
If your project was like mine, it has .kt files in /src/main/kotlin, some missing references in Java. I tried compiling them but nothing worked. It turns out that my project didn't have an Eclipse Source Folder associated with the kotlin code. There were the usual ones for "src/main/java", "src/main/resources" but not one for "src/main/kotlin".
So, I created a source folder for the kotlin files.
Right click the project
New "Source Folder"
Specify folder name: "/src/main/kotlin"
This doesn't create anything in the file system but just creates a logical container for Eclipse to work with the contents. In this case, Eclipse recognized the .kt files, compiled them and all the missing references issues all cleared up.

How to use eclim with gradle project

My eclim setup working perfectly with eclipse project. But I want to use gradle build system.
I am working with Libgdx framework and it provide gradle templete project.
So is there any way to use eclime + eclipse + gradle
Your best bet is to check out the Eclipse Gradle plugin, although in short you can add apply plugin: 'eclipse' to your project and then run gradle eclipse from your terminal in the root folder of your project. That should generate the necessary files for Eclipse to recognize your project, although you might need to edit the .classpath file for proper autocompletions.
That will get Eclim to recognize your project with :ProjectOpen and proper autocompletion and other goodness.
The bad is that Gradle tasks and changes to your build.gradle will require manual changes to the Eclipse side of things.
Edit: There's a new plugin available for this purpose that replaces eclim for gradle projects (but is android oriented) called Vim-Grand. It's pre-alpha and you'll want the refactor branch for now, but it's working well enough for me
You should combine it with YouCompleteMe.
What I did was use the gdx-setup.jar to create my project. I then imported it into eclipse like a normal gradle project. I closed eclipse and started up elcimd. Put "let g:EclimCompletionMethod = 'omnifunc'" in my .vimrc file. Followed the elcim instructions to use :CreateProject and that was it.
This guide was really helpful: http://www.lucianofiandesio.com/vim-configuration-for-happy-java-coding
I am able to get most or all Eclim functionality working with my libgdx project this way:
create a new libgdx project with their tools
start Eclipse
Import --> Gradle Project --> Build Model per usual libgdx project creation
shut off Eclipse, start Eclim
I get organize imports, java validation, autocompletion, all the good stuff.
That said, I want to figure out how to do this all without having to use Eclipse. I think the missing piece is the Build Models functionality. Still researching ...

Cordova (Phonegap) build undo my code changes in Eclipse

Once I create my Phonegap project through the CLI with:
cordova create hello com.example.hello "HelloWorld"
add the android platform and import the project to my Eclipse, every time I run a cordova build android command, it undo/reverts the code that I changed on Eclipse, looks like it always gets reverted to the original project structure created by Cordova CLI, maybe I missed something in the documentation... any ideas?
UPDATE
Ok.. So the plan will be, I will develop my app using the root files, i.e., within hello/www/* (instead of the files within hello/platforms/android/assets/www/*) because Phonegap will override any changes to the ones for specific platforms as part of its build process. My development workflow then involves TextMate to edit HMTL/CSS/JS and then running cordova prepare under the project's folder in order to update the files in my Eclipse project.
Anyway.. just sharing my solution workaround to the cumbersome development process for Phonegap + Android because, IMHO, the documentation around this technology sucks...

Eclipse Gradle dependencies are not updated in Web App Libraries

I have a Gradle project (imported and generated using Eclipse's Gradle plugin) in Spring Tool Suite edition of Eclipse (3.2.0). It works most of the time, but sometimes, dependencies are getting out-of-sync between "Gradle Dependencies" and "Web App Libraries" in the project. Here is what I mean:
I define a compile dependency as following:
compile(group: 'com.mygroup', name: 'myClient', version: '0.2.1')
Then, after I do "Gradle -> Refresh All" I see that the dependency lib "myClient-0.2.1.jar" is in the list of the "Gradle Dependencies", and in the list under the "web App Libraries".
Now, after some time, I decide to use a newer version of this lib:
compile(group: 'com.mygroup', name: 'myClient', version: '0.2.2')
I again do "Gradle -> Refresh All", I also tried to refresh the project, re-build it, open/close the project and Eclipse, but what I see is:
The dependency under the "Gradle Dependencies" is indeed updated and is listed as "myClient-0.2.2.jar". But, the dependency under the "Web App Libraries" refuses to be updated and stays as "myClient-0.2.1.jar". this, obviously, wracks havoc to my app as now my code is not referencing correct newer classes and shows up all red in Eclipse.
One workaround that works sometimes is to nuke the whole project, and re-build it from scratch, but this is rather more radical than what I'd like to do :) And it does not work sometimes. It looks like I cannot explicitly control what goes into the "Web App Libraries" - so even though I see that a wrong lib is listed in the Project -> Properties -> Java Build Path -> Libraries -> Web App Libraries - I cannot change it there.
Any insight into this would be much appreciated,
Thanks!
Marina
I had the same problem.
Try a gradle cleanEclipseWtp eclipseWtp, this worked for me.
The WebApp libs will be up to date.
Best regards
Max
1)delete it without deleting contents on disk
2)Import ... Existing projects into workspace and import the gradle-example project back
3)the Gradle Dependencies container is named nicely
4)restart Eclipse
5)the Gradle Dependencies container of the gradle-example project has the weird name I'm reporting

Building a workspace (J2ME) on Eclipse 3.6.0

I am beginning work on development/maintenance of a J2ME MIDlet application that uses the Nokia N97 SDK. As a first step (I have never developed J2ME/Java applications before), I completed the following steps on Eclipse 3.6.0 Helios:
Imported the project using the following step:
File -> Import -> Existing Projects into Workspace
Select root directory as TeleDB1 (the name of the directory that contains the files).
When I click on Finish after these steps, Eclipse automatically builds my new workspace. This step is unsuccessful. I get the following errors:
Errors running builder 'Preverification' on project 'TeleDB1'.
org.objectweb.asm.ClassReader.accept(Lorg/object/web/asm/ClassVisitor;Z)V
This is what I have tried:
1. Right-click on the project, Properties -> Java Build Path shows the following libraries:
a. org-netbeans-modules-mobility-antext.jar - missing
b. J2ME Library (failed to get library information).
These are my questions:
1. How can I get this project to compile?
2. How do I resolve the errors in the Libraries/Build Path?
I think I have set up my environment for running J2ME applications correctly.
I have situation as yours, and I find the way to solve it.
Right-click on the project---->properties---->j2me---->device---->manage device,choose a device you like.