Combining Git with Gradle and Various IDE's - java

I've been working on a Java project using Gradle in Eclipse that builds on my local machine and works just fine. I want the project to be available to a team of developers via Git, but after creating the repository and trying to build on a different machine using both IntelliJ and Eclipse, I'm realizing that there are some challenges. For instance, it seems like there need to be minor changes in build.gradle. Or in IntelliJ, JDK 1.8.0 must be specified for java.util.stream.
My goal is to create a project that allows a team of developers to simply clone the repository, use any IDE they want, build the project and begin contributing right away. Has anyone attempted to do this before with Gradle? What are some tips or insights? Is Gradle a poor choice for this? How can I standardize the build, libraries, etc.?

Related

Not all Gradle projects are created equal, according to Netbeans

I'm checking whether we'd be able to migrate from Ant to Gradle, but got confused right at the very beginning of these checks - Apache Netbeans 12 LTS (+ Gradle plugin from official repo) refuses to properly open Gradle projects that were created by a another Netbeans instance, which is a major pain.
I tried to open (in Netbeans) one of the Java library project examples from Gradle docs, only to find out the IDE immediately spews out errors (missing imports for tests) that are unjustified and offers a very limited amount of IDE integration - forget running specific tests, even debugging is all grayed out. Gradle and Netbeans also see different classpaths.
If I create a Gradle project inside Netbeans, everything works fine - no errors, Projects Tree shows an additional tree node, called "Configurations", like in the image below, I'm able to debug and everything just works.
However, even if I just copy/paste this project's directory to a different location, everything breaks after the project is reopened (I also get this issue, same thing happens for example projects found in Gradle docs).
What is going on here? Netbeans seems to know more about a project it created, than about projects that were created outside it or were just relocated. How do I force it to treat all Gradle projects equally (so that they work as expected)?
I used Gradle 7.0.1 and let the New Projects wizard "Initialize the Gradle wrapper" for the project created inside Netbeans 12 LTS. The setting to prefer existing wrappers is enabled in settings if relevant.
Enabling an "experimental" option in Gradle options, called Enable 'lazy' Source Group Initialization does help with simple projects that were created by Netbeans, so they open as expected.
But this does not work for Gradle projects that contain subprojects, such as the example project from Gradle docs:
The issue tracker for this Netbeans plugin has been quite active recently, mentioning issues like this, so perhaps there is hope.
At least part of the problem is that the LTS release of Netbeans (at the time of this writing) doesn't support gradle 7. The latest release, Netbeans 12.4, is the first version that supports gradle 7.

Java category missing in Apache Netbeans

So I installed Apache Netbeans. Installed some of the plugins and instead of just seeing the Java folder in the categories when I want to create a new Project, I see this:
What is Gradle, Ant, and Maven? I am not familiar with Java and wanted to study the language, but I have no idea of what these are.
I keep seeing that I need to have certain plug ins installed and active.
Here they are.
Ant, Maven and Gradle are Java build tools. You don't really need to know the exact differences though.
Java with Ant
The "Java with Ant" option uses NetBeans' own internal project format (based on Ant). In older NetBeans versions this category was simply called "Java"
If you don't need to share your project with non-NetBeans users, use that option.
You will have to manage dependent libraries yourself (download, add them to the project) unless you are only using libraries and frameworks that are bundled with NetBeans. The turnaround times (the time it takes between you hit "Run" and the application actually starts) are the shortest with this option, as Maven and Gradle add substantial overhead to that.
Java with Maven
Maven is a standardized dependency and build management tool. A project defined with Maven can be used by everybody else as it automatically manages (and downloads) any dependency.
Use that option if you know you need to share your project with other people (e.g. hand it in your school or university).
Java with Gradle
Gradle is yet another build tool, which also manages dependencies for your and has more flexibility than Maven. However the build scripts are less standardized than in Maven. But that is also a good option if you know that you need to share your project with other people.
Unless you are using NetBeans 11.1 (which is currently in Beta) I would not use this option as Gradle support in older versions is not as good as Ant or Maven support.
You might want to go through the tutorials on the NetBeans homepage:
http://netbeans.apache.org/help/index.html

How do I use LibGDX, Gradle, Git, and Eclipse together?

I have a LibGDX project for Android and Windows which I created with the LibGDX project setup app (https://github.com/libgdx/libgdx/wiki/Project-Setup-Gradle), and I have no problems running the project on my main development computer. I want to work on this project from multiple computers and with other developers using Git, and so I placed all three projects into a Git repository. When I try downloading and importing the projects from the repository, I get a bunch of Build Path errors in
Eclipse, since my main computer is a Mac and the other computers are Windows and Gradle downloaded the libraries for the projects to my User library (which I've always understood to be normal behavior). How do I fix this issue? Should my Git repository contain all the libraries, and then must I fix the build path by hand? If this is the case, what was the purpose of using Gradle in the first place?
If you have gradle integration with eclipse setup in all the computers, it will work if you do the following,
Do not commit any of eclipse metadata directories/files to the repo.
In the new computer (any OS) import(either after cloning externally or materializing from git) the gradle project and allow the tool chain to download dependencies and setup the eclipse project.

Setting different compiler levels for different source folders in eclipse in same project

I have a project that is build using ant and now i am trying to convert into one that is build in eclipse.
The ant files describes different compiler versions for different course folders i.e few are compiled using jdk 5, few using 6 and still few using 4.
How can we configure the project in eclipse to use different compiler levels in eclipse for different folders in same project.
I noticed that they had this bug lined up in eclipse and they said to release it on 3.5 and i am using 4.3. So it think the feature should be there.
Such feature does not exist. You will need to create multiple Eclipse projects.
I would suggest that you think twice before making a change in that direction.
ANT might not be the best build tool, but switching to Eclipse is way worse as you tight yourself not only to an IDE, but also to a specific configuration of both your instance and your project, making it less portable and more fragile than before.
I would rather suggest that you split your project into different modules/projects and use maven (integration with Maven and Eclipse is ok for simple builds) to organize both you CLI and Eclipse build procedures.

How to search sourceforge.net for Java projects that are built in Eclipse

Sourceforge.net has a filter for Java projects, but I'm looking for a way to narrow them down to ones that are meant to be built in Eclipse.
Edit I'm using Eclipse Metrics and Omondo plug-ins to analyze open-source Java projects. I'm looking for a quick way to find Eclipse open-source projects that can build quickly in Eclipse, so I can use these tools on them for analysis.
I presume that a project that is "meant to be built in Eclipse" is one that has an Eclipse .project file and other stuff checked into the source repository.
First, checking in Eclipse-specific stuff can a bad idea because it is easy to include stuff (e.g. build pathnames, preferences) that are specific to the developer. You then get problems if there are multiple committers ...
Second, this should unnecessary. Most of the stuff in the .project file can be generated when you import the project. If that's not possible, then the project should provide instructions for setting up the buildpath etcetera. (Note that if the project uses Maven, this is all taken care of for you.)
Third, any project worth its salt will include build scripts of some kind that allow you to rebuild without using any IDE.
Finally, any project that only supports building using Eclipse is excluding the significant subset of developers who use other Java IDEs.
Note that neither Maven or Ant builds require Eclipse to work. Both of these build tools can run from the command line, or from other Java IDEs.
OK. I understand your requirements now. You don't actually care what the project is ... or that it is sound / worthwhile project. You just need it for testing your plugin. (I won't comment on the "validity" of doing this. It depends on what you hope to achieve.)
I suggest that you install the m2eclipse plugin and look for projects with a "pom.xml" file. The projects don't need to be eclipse specific. The m2eclipse plugin automatically creates the ".project", ".classpath" and so on based on the "pom.xml" file. There's no need to exclude any particular version control system, because the m2eclipse plugin can import Maven projects that you checked out from the command line.

Categories

Resources