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

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.

Related

How to mavenize eclipse RCP application?

Current state:
Multi-module Java 6 project using Eclipse plugins, application is distributed for Windows platform only as an exe file with directories with many jars and some init and configuration files. These client distribution is build via Jenkins using Eclipse Buckminster plugin. These project was written around years 2010-2012 and desperately needs refresh.
I mavenized project, which means that each module has now its own pom.xml with dependecies. All modules were successfully built using mvn install command.
Question is how to build and distribute complete application with maven and say goodbye to jenkins & buckminster.
Where I see problem(s):
I don't fully understand what Buckminster actually do and how to set up properly OSGi/Eclipse Equinox launcher. There are few files like .cspex, .cquery, .rmap and even some Ant xml files where some magic happened, but it's not clear for me.
Is it even possible to use Maven (maven shade plugin) to build such app? Has somebody experience with it?

Combining Git with Gradle and Various IDE's

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.?

Grief with Gradle and Maven repository for Android builds

I have been having endless grief with Gradle for Android builds after I had to format my Macbook Pro for some stupid corporate domain migration. I have been using Gradle (both off the command line and with Android Studio) to build my projects for over an year now, and never had problems till the fresh install. I spent countless hours over the weekend trying to fix this, but with no luck, and I'm literally on the verge of tearing my hair out! Here is what I'm stuck with:
Gradle builds have slowed to a crawl
I have a multi-project (or multi-module in Android terms) project which used to take around 2 minutes for a clean build - plus uploading archives to the (local) Maven repository. Now,the Gradle configuration phase takes around 8 minutes! Nothing has changed, for after the fresh setup on the Mac, I just took a pull of the sources from the Github repo, and I'm building using the gradle wrapper (as before) which uses version 2.2.1. Not sure if this matters, but the Gradle version on my machine is 2.6. I use Maven - not for builds, but for the local M2 repository, and the Maven version is 3.3.3. Both Maven and Gradle were installed using Homebrew. The Gradle runtimes are the same whether of the command line or using Android Studio. I'm using Android Studio version 1.4-beta4. Here are the things I have set up:
I have set up the Maven settings.xml to point the local Maven repository to the default location `${user.home}/.m2/repository
I have set up Google repository using Android Studio and the Support repository (my project needs Play services and the support library)
We need to upload the archives to the corporate Maven repository on our build servers; to sidestep this, I use the gradle.properties to define the repository URL to be the local M2 repository that's set up in the Maven settings
The project defines Android build tools version 1.1.0, and while this is an older version, I tried with the latest 1.3.1 with no luck on the build times
Possibly related: my Mac Pro uses a good ol' HDD, not the newer solid-state storage. While that can impact build times, the disk was not updated during the format, and also, I presume that it shouldn't result in such multiple orders of magnitude impact
Failure in resolving artifacts from local M2 repo
The primary project that I work on is a library, and we have test clients that we use to verify functionality. The library and test clients are maintained as separate projects in the Github repo. To not have to make any changes in my local development setup, I prefer to deploy the artifacts from my library to my local M2 repo, and then have the test client define and resolve the dependency locally. I accomplish this using the global gradle.properties to override the repository URL (point it to the local M2 repo). This worked just fine till the disk format, but is broken since. Gradle is never able to resolve the artifacts, but I can see them in the local M2 repo. I have googled high and low (on Gradle forums, here on SO), but cannot seem to figure out what I'm missing or doing wrongly. As a work-around, I added the test client as a module to the library project, and am building it as a single multi-module project. BTW, even with this, I still run into the slow Gradle build times problem that I mentioned above.
Can someone help me out?
so there are a few Problems you got to adress:
1. gradle is not resolving the artefacts in the local repository
- maybe it corrupted during the formating (Setup a test Project using maven for
its build only, specify some existing dependencies if you want to verify).
A fresh setup of the repo could resolve this.
2. gradle build is slow
Well, without further Information hard to troubleshoot. Did you refresh your dependencies, clean up the Cache, have enough free disk space in the GRADLE_USER_HOME?
I figured it out. There's one little bit I'm still not able to grok, but that aside here is what was wrong:
Slow gradle builds
The project's build.gradle file had declared a dependency on our corporate SCM Maven repository. I replicate whatever dependencies my project actually needs in the local M2 repo. Once I replaced this with a file URL pointing to the local M2 repo, Gradle build times dropped to the earlier 30-40 seconds. The part I'm still confused about is that even with the remote repo, Gradle should have downloaded the artifacts once and cached them in the Gradle cache. Still need to figure out why it's not doing that.
Failure in resolving artifacts from local M2 repo
This was a bad error on my part. In my gradle.properties I'd listed the SNAPSHOT_REPOSITORY_URL override as /Users/me/.m2/repository (with me replaced with the username). I missed the file:// prefix here. I'm somewhat surprised that Gradle didn't call it out, and instead deployed the artifacts at the directory pointed by /Users/me/.m2/repository, but may be I don't understand how this works so well. Once I added the file:// prefix, all the test project builds worked like a charm!

Multi-project app in Eclipse with maven

I'm used to Visual Studio, so Eclipse is very new for me.
I have to start (ASAP) developing a project that contains 3 subprojects:
1 - Business logic library with Hibernate support
2 - JavaFX configuration utility
3 - Spring MVC app with a lot of JavaScript inside
2 and 3 use 1 as a core.
I've tried to google manual but all of them were about parts of this task, nothing about the complete solution.
I can create all 3 projects and put them in same subdirs in a solution directory. But how to connect them to core lib? Maven looks great for it, but I can't explain him how modules have to be connected.
How to make such a structure?
At the risk of being shot down in flames, in my opinion Eclipse does not handle structured projects as well as Visual Studio. (I program Java/Eclipse at work and use VS aka Atmel Studio at home for hobbyist C++/Arduino projects).
In Eclipse, I have found to best to check out each component to the top level and compile each component separately (mvn clean install). The output of this is generally a .jar file that will be installed in your local maven repository. You then list that jar as a dependency in the pom.xml file of the higher-level components.
I suggest you install M2Eclipse or some other Maven client into Eclipse. They are not perfect, but are far more productive than doing everything manually.in my opinion.
Also Eclipse supports multiple workspaces quite well. One workspace per major multi-component project works well.

how to use maven (eclipse keppler) on imported non-maven projects

I have existing projects that I wrote using Eclipse Juno on another machine, on that machine I downloaded the jars I needed (selenium, jxl, sqlite etc.) from the internet manually and then edited the build path to point to them. I need to move these projects over to a different machine which has Eclipse Kepler loaded. I thought I'd use maven to link everything up (with a view to retro-fitting the machine with Juno to use maven) so that as I jump between the two machines everything will be kept in order automatically.
I installed maven from the marketplace and ran the install:install-file command, but it won't run the program as it insists the jars it's looking for aren't installed (which of course they aren't, that's what I thought maven did).
Is it not possible to use maven in this way (get it to download and link up missing jars) for an existing project? Do I need to do it manually, and if so will I have created problems that I'll have to unpick by having tried this with maven?
If you're using the m2e plugin, you can turn on Maven dependency resolution by just right-clicking on the project and choosing Configure->Convert to Maven project. Make sure your project has a valid pom.xml file and set everything up properly in Preferences->Maven (proxy, user settings, maven installation, ...)
If you're not using m2e, you can use the eclipse maven plugin like this:
mvn eclipse:eclipse
This will call the eclipse goal of the eclipse plugin, and it will generate .project and .classpath files for you with all dependencies pointing to your Maven local repository.
As a side note, the install:install-file goal doesn't have anything to do with what you want to achieve, it's used to install an artifact (a .jar file) to your local Maven repository.

Categories

Resources