Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rearrange project to build with maven #2

Merged
merged 1 commit into from
Aug 18, 2015

Conversation

ruckc
Copy link
Contributor

@ruckc ruckc commented Aug 18, 2015

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

@eugener
Copy link

eugener commented Aug 18, 2015

This is great! I also suggest:

@RobertBColton
Copy link
Owner

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
Copy link

eugener commented Aug 18, 2015

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

@RobertBColton
Copy link
Owner

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
Copy link

eugener commented Aug 18, 2015

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
Copy link
Owner

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
Copy link

eugener commented Aug 18, 2015

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

@RobertBColton
Copy link
Owner

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
Copy link

eugener commented Aug 18, 2015

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

@RobertBColton
Copy link
Owner

@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
Copy link

eugener commented Aug 18, 2015

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

@ruckc
Copy link
Contributor Author

ruckc commented Aug 18, 2015

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

@RobertBColton
Copy link
Owner

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
Copy link

eugener commented Aug 18, 2015

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
Copy link
Contributor Author

ruckc commented Aug 18, 2015

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
Copy link

eugener commented Aug 18, 2015

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

@RobertBColton
Copy link
Owner

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 RobertBColton merged commit 6578f24 into RobertBColton:master Aug 18, 2015
@RobertBColton
Copy link
Owner

@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
Copy link

eugener commented Aug 18, 2015

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

@RobertBColton
Copy link
Owner

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
Copy link

eugener commented Aug 18, 2015

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
Copy link
Owner

@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
Copy link

eugener commented Aug 18, 2015

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
Copy link

eugener commented Aug 18, 2015

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

@RobertBColton
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants