RobertBColton / DockFX

A fully featured docking library for the JavaFX platform.
Mozilla Public License 2.0
278 stars 105 forks source link

rearrange project to build with maven #2

Closed ruckc closed 9 years ago

ruckc commented 9 years ago

I'm not an Eclipse user, so I rearrange the project for Maven. I also incorporated the Google Java checkstyle guidelines.

eugener commented 9 years ago

This is great! I also suggest:

RobertBColton commented 9 years ago

Hi @ruckc ! Thank you for your contribution, I've not worked with maven before so please give me a bit to download maven and make sure everything works out. I will get back to you shortly, please bare with me. :D

eugener commented 9 years ago

Maven and support for it is actually built into all latest versions of Eclipse

RobertBColton commented 9 years ago

Hi @eugener so it is possible I can keep my existing jar descriptions and support both? Just let me make sure it still builds alright. Can someone clarify the reason for the inclusion of the Google checkstyle guidelines? I use the XML formatter imported in Eclipse I am not sure if this is a duplicate of that or something else I hadn't considered.

eugener commented 9 years ago

Yes... it will support both. The reason for maven and other tools is that not everyone is using Eclipse. In fact most people don't. You also need to be able to build your project from command line for CI purposes Let me know if you need some help with Maven here.

Alternatively, in ControlsFX, we use Gradle, which is already configured.

RobertBColton commented 9 years ago

Alright that sounds reasonable. I am actually interested in working to get a future more complete and integrated version into ControlsFX so perhaps going with Gradle would be better. Would that satisfy this pull request owner's needs?

eugener commented 9 years ago

Either Maven or Gradle will do, but PR sender did the work configuring project with Maven

RobertBColton commented 9 years ago

Alright i understand I've pulled locally and it seems fine the layout is similar to Gradle's, while I have used neither Gradle nor Maven I've been reading up on both. It's failing to import in Eclipse right now. If I can fix the Eclipse project and get it working I'll push it into master with the fixed Eclipse project.

eugener commented 9 years ago

Re-import as Maven project, which will auto-modify your Eclipse configuration

RobertBColton commented 9 years ago

@eugener Alright that is one step closer, will I need to update the import statements? It's failing to build right now because he did not update the import statements or I am unsure if I've simply imported the project wrong.

eugener commented 9 years ago

Maven is just a build tool. Change your code as much as you need.

ruckc commented 9 years ago

I didn't update the eclipse project files. I didn't want to break those further.

RobertBColton commented 9 years ago

It is ok ruckc, I am willing to go with this just please excuse me for not having used Java CL tools before. It is building after updating the package name in all the sources however I am getting an exception.

Image dockImage = new Image(DockFX.class.getResource("docknode.png").toExternalForm());

This in the demo.DockFX where I load the test graphic. This is erroring because it's in a resources package separate from this class. What is the appropriate way to load this file now?

eugener commented 9 years ago

The way Maven plugin in Eclipse works is it keeps your Eclipse project configuration in sync with your Maven one. This makes a lot of sense and allows you to work in Eclipse using maven project. Usually IDE specific files are not committed into source repositories. To ease you pain of testing, just create a new branch and modify everything there until it works. You can later merge it into master

ruckc commented 9 years ago

I moved the graphics and css into src/main/resources. Maven/Gradle convention has them in separate paths, but merged in the final jar.

eugener commented 9 years ago

Yes.. should work exactly the same way because it is brought into the same location during the build

RobertBColton commented 9 years ago

Hrm, I must be missing something in the pom.xml I see org.dockfx which I think indicates that nothing should be changed. @ruckc Do you think it is possible you could fix the Eclipse project? I generally use command lines only for C++ and I would switch to one for Java but I only touch Eclipse because of the awesome code refactoring.

RobertBColton commented 9 years ago

@eugener @ruckc I got everything working, the jar description's are still broke but as long as I can run this from Eclipse everything is fine. Thank you!

eugener commented 9 years ago

There is no need for jardesc files anymore - your pom.xml describes everything. Simple mvn package command will make a jar

RobertBColton commented 9 years ago

Oh excellent that was as I had assumed. I've configured the environment variables and Maven seems to be working. After that command I have the following:

EclipseWorkspace\DockFX\target\dockfx-1.0-SNAPSHOT.jar

However I believe this is configured to build the library? I'm not sure where the demo has outputted to and am unable to find it.

I really appreciate your guidance.

eugener commented 9 years ago

I'm sure it is part of your jar. You can run it by specifying the main class. Also you don't need to install maven. It is part of your Eclipse already. Just use Run as context menu on your project

RobertBColton commented 9 years ago

@eugener Alright from the following link I think I know how to get it. Is it reasonable to use a separate pom.xml file for my demo? Such as pom-demo.xml? I am not looking to specify a main class for the library. http://www.avajava.com/tutorials/lessons/how-do-i-specify-a-main-class-in-the-manifest-of-my-generated-jar-file.html

eugener commented 9 years ago

Not really. Just describe the main class + manifest in your pom.xml. This will make your jar runnable and it will run your demo by default. At the same time It could be used as a library.

eugener commented 9 years ago

Check out this link http://www.vogella.com/tutorials/EclipseMaven/article.html It is a good starting point on Eclipse+Maven

RobertBColton commented 9 years ago

Great that link fixed everything! For now I guess we'll just always use the demo as the main class, so I made the demo run without the presence of the readme.html which is optional.

Later it can be configured through a profile to set the main class and copy the readme.html to the target/ folder. http://www.jpeterson.com/2009/08/25/using-a-maven-profile-to-run-a-test-program/

Thank you for all of your help!