Gradle and Eclipse - java

I am new to the whole Gradle thing and I find amazing already. I am experimenting with the tutorials they offer on their website on how to setup a project, build etc etc. My question is the following.
I have successfully set up my first project, build it and run it. After this Eclipse shows an error about not being able to find library imports (the ones resolved automatically by Gradle). How am I supposed to fix this?
Also are there any good addons for Eclipse that offer Gradle commands (I am currently building the project by running the command on Cygwin) as well as syntax highlighting for build file?

Related

Eclipse-project to makefile for ant/maven/gradle/

Today I faced problems in starting eclipse (reinstall etc. did not work). I had to use a vanilla eclipse and with luck it was working.
With that I experienced the problem of an IDE that is not working. That can be a mess if you need a quick bugfix for a hot system.
Is there a tool that takes an eclipse-project and converts it into a makefile for a more basic tool (like ant, maven, gradle, ...) that work from the commandline?
Sure I can make it by hand but because it should be only a safety I would prefere the automatic way and keep the development-work in the IDE.
EDIT:
Or maybe: Is there an build-command that works on the commandline without starting the IDE?
Thanks!
Running "gradle init" from the command line will attempt to create a build.gradle for your project. If your project layout is "conventional" it might do a good job. If it finds anomalies it tends to give up. Constructing a simple Gradle build script for a simple project takes a few minutes once you get used to it. Searching the web with intelligent queries will tend to find lots of examples.
Adding the "Gradle Nature" in Eclipse is simple if the project is buildable from the command line with Gradle.
You can use m2e eclipse plugin to convert your existing projects to maven projects. But you have to do it before hand(while your eclipse is still working)
https://crunchify.com/how-to-convert-existing-java-project-to-maven-in-eclipse/

Java project from existing ant build file doesn't appear as in version control

I have a repository in which I have a simple ant project (only the src directory and the build.xml file). I did a checkout of this project in a local copy. Then I opened Eclipse, created a "Java Project from existing Ant build file" and it worked fine. I can build, clean, run, generate javadocs, etc. However, my problem is that the source files in the packages, as well as the project itself, doesn't appear to be under version control in Eclipse. I can work with it fine from Cygwin, but not from the GUI.
The odd thing is that I have several regular Java projects, on the same repository which are synced fine by Eclipse, so it's not a version issue.
When I created the projects that work, I had to go to Team->Share Project... and Eclipse told me that they were already under version control and updated its configuration. However, in this current case, this isn't working. Any suggestion please?
EDIT:
I'm using svn 1.8.
UPDATE: I tried creating a regular Java project, and this time the version control looks fine, so it appears it's an issue related only to Java Project from Existing Ant build file.
The problem is that Eclipse doesn't know your project is using Subversion as a version control tool. You did a checkout outside of Eclipse, then you set up Eclipse as if this was a non-version controlled project.
To get Eclipse to recognize the project as under Subversion, you need to let Eclipse know. This means you should have said "File->New->Project, and select SVN->Checkout Project from SVN in the new project wizard. Then, Eclipse would have checked the project out in Subversion for you, and Eclipse would understand this project is in Subversion.
Unfortunately, I am not quite familiar enough with Eclipse to know how to tell Eclipse that the current project is really under version control. The best I could come up with was:
Right-click on the project and select Team->Share
Say this is a Subversion project you want to share.
Select the Repository to use
Select the folder where you want this project, and select the current folder.
You get the following warning:
Warning: The specified folder already exists in the repository. If you continue, that folder will be checked out to the existing location. Do you want to continue?
Your project will now be "checked out" over your current project. Everything should be okay because the files you have either match what is in Subversion or are modified versions of what is in Subversion.
You will be then asked to use the Synchronized view. Check "Yes", and then switch back to the Java view. Eclipse will now know your project is under Subversion and everything should work fine.
Note the use of Shoulds and Coulds. This is my way of saying that the advise given is done on an "as is" basis and I am not responsible for any damage done by following this advice, so please don't sue me.
It's basically your standard open source license.

Idea + Play Framework - cannot resolve method/symbol

I use IntelliJ IDEA 12, Play 2.2.0, I have Scala plugin installed, Play 2.0 support plugin installed.
I created java play application via termina (play new). Andas you can see in this pictures I always get this error: "cannot resolve method ok()" or "cannot resolve symbol at"
http://sluchatka.kvalitne.cz/pics/1.png
http://sluchatka.kvalitne.cz/pics/2.png
I searched the web for this problem the whole day, but I didn't find solution.
Can you please help me?
The first problem (unable to resolve reference to template) is because your template probably has not been compiled by the moment (and thus IDEA does not see compiled template and can't resolve reference to it).
I usually develop Play apps having ~run command launched in Play console. So that any changes to templates are immediately compiled and changes detected by IDEA.
As for the second one it seems like a deficiency in Play IDEA plugin. It does not work seamlessly within templates I should say. Lots of glitches. The best way I found is to have ~run launched so that small problems are detected immediately.
According to intelliJ support it is better to import the command line created play 2 project using the IDE import project wizard instead.
File -> Import Project
Select play2 project location
Import as SBT project
This was due to the "play idea" command being outdated or not fully compatible with the current play 2 and scala plugins for intelliJ.
A bonus is that errors start to appear properly, we had trouble with that earlier.
I was having a similar issue with Play 2.4.2 and Intellij 14.1.4. I could run the basic "play-java" example/starter app in Intellij, even though the editor showed errors like "cannot resolve method ok()".
Here's what solves the problem for me:
Before starting, make sure your project is not open in Intellij.
Delete the ".idea" folder from your existing app, OR just create a new app using "activator new".
On the command line, cd to the app's folder and compile using "activator compile".
In Intellij, File -> Open, and select your app's folder. For the SBT import options, I left the boxes unchecked (e.g. "Use auto-import", "Create directories for empty content roots automatically", etc.) but I don't think it matters.
Once everything finishes loading, you shouldn't see the errors any more.
This click in the Project Structure is your answer.

NoClassDefFoundError when referencing from an Android-Project to a standard Java-Project

I am currently working on an android application that needs to use some shared classes which are also used on some serverside.
So on the one hand I have this standard java project inside eclipse where I have some POJOs, infercaes and so on. And on the other hand I have an android application project with an activity that should use those POJOs.
My first try to get the android project to know the java project was simply adding it as a "required project" in the build-path properties inside eclipse. That resulted into:
java.lang.NoClassDefFoundError: my.package.Pojo
I googled it and tried a lot, but still the question stands:
How do I set everything up properly, so that my ADT v21.1 android project will still know my java project, even at runtime?
Some things I already tried that did not seem to change anything:
after adding the "required project" I also set the dependency to be exported under eclipse "Order and Export" dialog
I tried building the java project as a jar-file and adding it as a jar-dependency to the android project
I created a android library project as 'glue': I added the java project as a dependency to the library project and the library project as a 'android dependency' to the android project
I checked that all projects where inside the filesystem in the same parent folder (read, that the underlying ant task might have some troubles otherwise)
I googled for a loooong time
Would really be nice if someone could help. Maybe I'm just missing some tiny little thind?
Bluddy
The Problem is that I build the java project using Java 7 which seems to by not supported by android. 'Phix' pointed that out in his very helpful posting (he was also andwering himself):
https://stackoverflow.com/a/13304441/1145459
(answer by Bluddymarri, I just posted it here to help him get it closed)

How to create a build job for a simple java project

I am very new to Jenkins. I have gone throught the tutorial of jenkins and I want to create a build job for simple java project. I know how to create a freestylebuild but I dont see any connection between the build and the project. Whats happening exactly. I have my project in eclipse and how can i create a build to the project. How do i know that it is the exact build for this project.
Can anyone please help me.
the best thing to do would be to move your build to some standard command line tool, like ant, maven, ivy, gradle etc and then you can reuse the same build from your IDE and on jenkins. note that this doesnt mean giving up using your IDE - many IDEs can import these types of projects directly and give you all the benefits youre used to in an IDE. it simply means that you get a build thats "portable" and not tied down to the specific IDE your using.
personally i think maven is best supported in this regard, but its mostly a matter of personal preference.

Categories

Resources