How to import playframework sources into eclipse? - eclipse

After cloning playframework from github and importing java sources into eclipse there are a lot of build errors shown.
Running the goals from ant file in eclipse works fine as well as building from cli directly.
How can i resolve these errors in eclipse?
I took the following steps to import play into eclipse:
new -> other -> Java>New Java Project from Existing Ant Buildfile
select play/framework/build.xml
checking the 'Link to the build file in the file system' checkbox
Finish

The errors result from differences between eclipse internal build path
and classpath available for ant at runtime.
First Eclipse only imports rt.jar from system path. This may lead to
missing dependecies in javax.net packages (e.g.
javax.net.ssl.SSLException), which is located in jsse.jar. To fix, right
click on project->Properties->Java Build Path->Libraries->Add Library->
JRE System Library.
Second, play has dependencies to classes from ant runtime. To fix, right
click on project->Properties->Java Build Path->Libraries->Add
Library->User Library
There you have to add a new User Library (perhaps call it ANT) and add
all ant-jars from your ant installation (/usr/share/ant/lib/ worked for
me). Then add this user library to play projects build path.

From the Oliver's answer, I had also to add the jce.jar lib in my classpath.
It comes from the $JDK/jre/lib directory.

Related

Project not built. Build path incomplete. Repairing build path did not work

java version "10.0.1"
Eclipse jee 2018-2019
Windows 10
I'm just trying to add a simple file to my package. After adding the file, I get the below error.
The project was not built since its build path is incomplete. Cannot
find the class file for groovy.lang.GroovyObject. Fix the build path
then try building this project.
Pretty much all posts say to delete the JRE System Library and add it again, do a refresh, clean restart. I did this, but I'm still getting a build path error.
I followed these instructions. Other forums on stack say similar things.
http://hemant-vikram.blogspot.com/2012/07/eclipse-build-error-project-was-not_12.html
New to Eclipse and Groovy. I just want to follow the tutorial :|
If you have added references to Groovy types, you can add Groovy libraries to your classpath by right-clicking on your project and choosing "Add Groovy Libraries to classpath". This assumes you have Groovy Development Tools installed.
Or you can add "org.codehaus.groovy:groovy-all" through Ivy, Maven or Gradle if you are using one of those for dependency management.

How to add external libraries in a Play2.1 scala project?

I want to use scala compiler library, and add it in Eclipse,
but when compiling the project again using eclipse, the library is deleted automatically by the compilation. What's wrong with that?
So the question is: if my play project want to use scala-compiler.jar, how to add that?
it does not work by using build path-> configure build path... in eclipse...
I also tried to put all the jar files to the lib/ folder, but when compiling again in the server using eclipse, it still gives out compiling errors because of not finding the jars.
Thanks in advance,
The most failure-proof way to add it is to use Play's configuration builder, not adding it explicitly with Eclipse. To build a correct Eclipse project, use:
$ play
[YourProject] $ eclipse
[info] About to create Eclipse project files for your project(s).
[info] Successfully created Eclipse project files for project(s):
Then you can import it from Eclipse under File/Import/General/Existing project… (see here for more).
Note that Play uses sbt, which is already configured to use some version of Scala.

eclipse ant integration and code formatting

I have configured Eclipse to use ant for doing the builds by setting the builders in project properties to point to the ant build script.
The build goes thru fine. However in my eclipse project I have not imported the required jars as a part of the project settings. All of this is done in ant's build.xml.
So in the java files, I get red squiglly lines for all the import packages which eclipse is not able to resolve.
How do I make these squiglly lines go away? One way is to import the required jars in eclipse, but then I am maintaining the project at two places, ant build.xml and eclipse
go to Project Properties/Build Path and enter the jars you rely on there.
You could use Ivy to manage your dependencies. If you configure it properly, you will only be defining the jars in one place but both Eclipse and Ant will be able to see them. The eclipse plug-in is IvyDE.

NetBeans -- Is it possible to bypass the IDE-generated Ant build for an existing project?

I have a Java project with sub-projects that is currently built using NetBeans's IDE-generated Ant scripts. I am converting the entire project to a Maven build.
My Maven build works fine from the command line and loads perfectly in Eclipse. However, the only way I can get the project to load as a Maven project in NetBeans is to delete the Ant scripts, i.e. build.xml and the directory nbproject for each sub-project. It seems that as long as I have the old IDE-generated build files, NetBeans recognizes the project as a NetBeans Java project only, not as a Maven Java project, even though there is also a pom.xml file present.
Short of deleting the IDE-generated build files, is there any way to tell NetBeans to load the project as a Maven project?
I have been told that we want to keep the Ant build for a while during the transition to Maven.
Using NetBeans 6.9.1, Maven 2.2.
Any help would be appreciated.
Thanks
Well, the nb ant project metadata has precedence over occurence of pom.xml file (that's how maven projects are recognized and loaded). The whole precedence order hardwired in the IDE, you could only influence it be uninstalling the j2se ant project type for example.
So, yes. You need to get rid of the ant project metadata before you can open the project as maven project. Depending on how and when you delete the metadata, you might need to restart the IDE as well to get the new stuff loaded.
Have you seen http://wiki.netbeans.org/MavenBestPractices? It indicates that you must install the NetBeans maven plugin first. Perhaps that's why your Maven projects aren't recognized.
I must note that I'm not a NetBeans user anymore!
Here is what I ended up doing:
I wrote an Ant script (ironic, huh?) that, for every subproject of my project, renames the file nbproject/project.xml if it exists to nbproject/nb_project_disabled.xml. If nbproject/nb_project_disabled.xml exists instead, the script renames it back to nbproject/project.xml. In this way, the script toggles the opening of the project as a NetBeans Ant build or as a Maven build.
It would be nice if NetBeans, you know, had a setting to open both kinds of projects. Currently (6.9.1), there is just the "Open Project" command. In Eclipse, there is the command "Import Existing Maven Projects" vs. "Import Existing Project Into Workspace" (i.e. native Eclipse format).

How can I reference ANT HOME from the libraries in the properties of a project when using eclipse?

In our code base we have a dependency on the ant version used in eclipse.
In the the ant.jar has been set up as a library which the project uses
This is a pain when moving versions of eclipse as the Ant plugin folder name changes (although I see it is now just called Ant1.7)
Is there a way to access eclipses reference to ANT Home which appears in the workspace preferences so that I don't have to explicitly set a variable that has the hard coded path to the ant plugins folder
Your project should not have a dependency on eclipse's version of Ant in the first place, you should keep your own version so as to decouple your project from eclipse. What if a developer or yourself decides to use intelliJ?
Although i don't know what the nature of your project is, i would have thought all dependencies should be added to your projects lib directory or something similar.
One possible suggestion would be to :
transform your project into a plugin project (properties on your project / PDE tools / convert Project to Plug-in Projects...) and
add to its dependencies the 'ant' required plugin.
That would be easier to manage when you change the version of eclipse.
Have you considered installing Ant separately, creating an environment variable, and then referencing the location via the ANT_HOME environment variable within your Ant build.xml?
From within your eclipse, on the package explorer view, right click on the specific project and build path.
Move into the Libraries tab and select the "Add Variable..." button. From here you'll see that is where the JDK system libraries path, maven(if you're using it, tomcat, eetc...) If ANT_HOME doesn't appear, you can add it by clicking the Configure Variables... button. From this moment, the ANT_HOME path will be considered in the build path of the project.
Hope it helps.
Carlos
Your ant home is available in the property ${ant.home}
E.g:
<echo> ${ant.home} </echo>
Gives the following on my machine:
[echo] D:\java\eclipse_3.4_jee\plugins\org.apache.ant_1.7.0.v200803061910