How to share code between Eclipse Swing/maven and Androidstudio / gradle project? - java

I am an experienced Java developer with years of familarity with Eclipse and Maven.
My goal is to create an android application and I am getting familiar with the latest Development environment Android Studio 2.3.2 which obviously uses Java 8 and Gradle. The app shall share code with an Eclipse based project that uses maven and Swing and is also Java 8 based. I am intending to publish the result as an open source project on github.
I found e.g.
https://github.com/uhafner/android-config as an example but that seems to be outdated.
https://github.com/cgeo/cgeo - which explictly states that eclipse is only used for codewriting/testing
Gradle project for plain Java and Android with single source tree suggests an answer for a gradle only approach that has a tutorial link as an answer (which is not accepted) and no example
https://github.com/javadev/calc which is purely maven driven and has two pom.xml files
https://github.com/adrian/upm-swing and https://github.com/adrian/upm-android simply have copied subdirectories instead of any kind of shared config management
How feasible is a combined maven/gradle project structure?
What would be a proper way to structure the project files to accomplish the above goals?
What are good examples projects that follow a similar approach?
My reason to be reluctant with Gradle and IntelliJ is obvious. It is an unfamiliar environment for me and android is not the main target of my development.

Part of the answer seems be covered at:
Can Android Studio be used to run standard Java projects?
I got somewhat of a success with the project https://github.com/BITPlan/can4eve
but would appreciate some help on the android studio / gradle side of things.
The project also has travis support built in and I am also running nightly Jenkins checks based on maven.

Related

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

Can Java Netbeans desktop application and Maven work together?

I have developed a java desktop application in netbeans 8.1 for a security project I am currently busy with.
I have been asked by the client to add Google drive or DropBox to the desktop application for storing the data files on the cloud storage at any of the two mentioned above.
I have done research and have seen that the only way to get this to work is to use Maven or Gradle.
I have picked up that there is Maven projects in Netbeans, But I would like to know if the following is possible:
Would it be possible to just copy the desktop application to the Maven created project?
Do I need to use the dependencies to add the jars needed for the desktop application classes?
Will I need to re-download the jar files or how can I add the jars that I currently have on the computer to the Maven project?
Will the copying of the normal desktop application to the maven project affect any of the other features created previously?
Does the Maven project work differently from normal java desktop applications created in Netbeans?
I would be very grateful for answers to this or any other information that would help out. I do not want to start this transition and land up it not working out.
Any information will be tremendously helpful.
Much appreciated for your help
At work here, most java developers use netbeans with Maven.
Netbeans for java is built around Maven.

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 do I migrate an Eclipse GAE project to Maven such that it won't be tied to Eclipse?

I have an open source Eclipse Google App Engine project (it's called LastCalc and it's open source, you can find it here, created using the GAE Eclipse plugin.
The problem is that several months ago I switched IDEs to IntelliJ IDEA. Since most of my projects were Maven-based this wasn't an issue, but LastCalc was stubbornly tied to Eclipse.
I'm hoping that someone can suggest an easy way to migrate this project to Maven such that it will work nicely in both IDEA and Eclipse.
We released the app engine maven plugin and a gustbook sample with that plugin. I don't think the manual migration is very difficult. You can create a directory structure similar to our guestbook sample and copy your source and resource files. Dependency might be a bit cumbersome, so maybe you can try the 'Convert to Maven Project' functionality of the newer version of m2eclipse.

How to add Maven to an existing IntelliJ Android project

I've been doing some research on adding Maven to an existing Android project and I'm struggling to see how this works. I've used Maven once at work on a web based project with Netbeans, but for this project I'm looking to use IntelliJ. I can create a new "Maven Module", but I already have an Android project so I'm not entirely sure that's the route I should be taking.
I found this post which does provide some detail, but not a step-by-step windows integration guide (at least that I'm seeing).
Is it possible for me to use Maven within an Android project?
Edit: I'm looking to do this within a Windows environment
To answer your question in the last sentence: Yes, you can use Maven to build an Android project.
You should use the maven-android-plugin in your Maven project. The best place to get started is https://code.google.com/p/maven-android-plugin/wiki/GettingStarted. Need to read up a bit, but definitely worth the effort.
If I have existing IDE specific Android project that you would like to switch to Maven, instead of trying to "add Maven support to an existing IntelliJ project", I would:
Create a new Maven based project using an appropriate archetype https://github.com/akquinet/android-archetypes
Copy existing source/resources to the Maven project directories.
If done correctly, you can open this (Android) Maven project (pom.xml) in IntelliJ and use it like an Android project (including GUI editor). IntelliJ automatically generates an IntelliJ project from Maven's pom.xml and detects the Android facet.
This way, your project also stays IDE agnostic - you can do everything (build/test/deploy) from command line as well - how Maven projects should be IMHO. :D

Categories

Resources