PeteManchester / MediaPlayer

61 stars 20 forks source link

Use Maven #8

Closed triplem closed 10 years ago

triplem commented 10 years ago

I would like to change the build infrastruture and use Maven instead of ANT. Furthermore I would like to suggest to use github and make releases (with tags) and then add the release to the github release itself or to bintray.

What do you think?

This would give us quite some benefits. We could generate a project page without a real hassle, we are not storing binaries inside the git repository (well only some, but not our own at least), we have a clear separation of the plugins, we can make clean releases and have a clean and "standard" directory strucutre, so that other contributors do find themself comfortable quite easy.

I will push a first draft to my own fork of this project.

PeteManchester commented 10 years ago

I would be willing to consider using Maven instead of Ant but have a few questions.

At the moment I use Eclipse to develop, build and distribute the files to my raspberry pi's. What advantage would Maven provide for me. Will I still be able to use Eclipse as I do now?

Can you explain more about what you mean by having a clear separation of the plugins, at the moment they are in the same code stream as the MediaPlayer and so I can easily debug the plugin code.

The ohNet libraries are often updated, will it be easy to push the updated ohNet libs to Maven?

if we don't store the binaries in GitHub where would they be stored and how could the binaries be distributed, at the moment at GitHub we have all the documentation and binaries in the same place.

Cheers,

Pete.

triplem commented 10 years ago

Sure, more then willing to answer ;-)

If you use eclipse, you do not need to change your workflow at all. Maven is tightly integrated to eclipse (IMHO) using a plugin. Maven can generate your whole project settings (for eclipse, as well as for IntelliJ, which I do use, as well as ...). The only difference in the workflow is, that the IDE needs to get configured to use Maven for the build instead of Ant.

I have now stored each plugin in a separate sub-module of the main project. If you take a look into my forked repo, you will see, that there are some sub-directories named "plugin-*". The plugins are stored in there and do have their own dependencies as well as their own source directories. This way a plugin has to follow the same versioning scheme and uses the same properties then the master, but can have e.g. own dependencies (like done for the AlarmClock-Plugin, which does contain SLF4J).

Of course you can push your changes as often as you like to. the above mentioned ohNet-Libraries are stored inside the github repository anyway, and not in any Maven repository, which of course could be changed as well, to follow the rule of strict separation of binaries and sources.

Github (or the git repository, that is) is not a place to store binaries in. This should be done in a binary repository. This binary repository can be any place you can think of. I am investigating bintray as well as oss.jfrog.org for this. But also we should think about using sf.net for the binaries as well as (if wanted) on an own server. The documentation could be stored on github pages, if wanted, and the binaries can the be easily linked in there.

Git is not really good in storing binaries and diffing them, and since it is a decentral scm, each version of the binary will land on all disks of all developers/contributors/interested persons. Right now, the repository is already nearly 45MB, which seems to be quite large for some source code. Each change on one of the ohNet Libs will increase the size by the size of the lib.

Whatsoever, because we are using same native libs, there seems to be nowhere then the github repository to store those. Other projects (e.g. the pi4j) are storing the sources in their github, but this would mean, that all architectures should be build by each release (which is of course possible as well, but means a slightly more complex build setup). At least we should avoid to store binaries, which are downloadable from e.g. Maven Central (mvnrepository).

Did I answered at least a part of your questions?

R,

Markus

PeteManchester commented 10 years ago

Ok, let's go for it...

Thanks..

triplem commented 10 years ago

On my way to test this out. I have already opened a private remote maven repository over at bintray.com, so that we can put our releases there. This needs to get implemented into the maven stuff.

You can take a look at the progress over at my own repository.

PeteManchester commented 10 years ago

Hi Markus,

It looks interesting..

Do you know what is the procedure would be to import into Eclipse and then to run the code in debug mode?

I have installed the Maven Integration plugin and the EGit connector for Maven and so can import from GitHub,

What are the procedures from then to build. debug etc..

Thanks,

Pete.

On 4 February 2014 19:00, Markus M. May notifications@github.com wrote:

On my way to test this out. I have already opened a private remote maven repository over at bintray.com, so that we can put our releases there. This needs to get implemented into the maven stuff.

You can take a look at the progress over at my own repository.

Reply to this email directly or view it on GitHubhttps://github.com/PeteManchester/MediaPlayer/issues/8#issuecomment-34094162 .

triplem commented 10 years ago

You should be able to create the Eclipse files automatically using mvn eclipse:eclipse or import the maven project directly in eclipse using the m2eclipse plugin.

You can build the project by right-clicking on the pom.xml and tell eclipse to build the project using maven (IIRC). I am using the command line for this with mvn clean install.

Debugging is possible by remote debugging or if you have unit tests, you can run those using the debug target. I am currently working on getting the classpath inclusive the platform specific binaries.

PeteManchester commented 10 years ago

Hi Markus,

Not being able to debug the source code in Eclipse is quite a big loss, this is how I do most of my coding, especially when I am working away from home and just have my laptop to work on.

Cheers,

Pete.

triplem commented 10 years ago

Debug is now possible with

mvn clean test -Dmaven.surefire.debug

Then you are able to remote debug the application for unit-tests (there is right now only one in the LastFM Plugin. The application itself will be debuggable as well, I am working on this one, or we can write an easy test to start the application itself.

Other then that please take a look on http://triplem.github.io/MediaPlayer ;-)

triplem commented 10 years ago

Hi,

I have made quite some enhancements to the maven build process (see notes.txt for some instructions). Please take a look on this. I would like to merge the projects together, before starting a new plugin to avoid duplicate efforts.

triplem commented 10 years ago

Oh. one note. The merge process could get complex. This is because you made changes to files which I moved and did changes on those as well.

PeteManchester commented 10 years ago

Hi Markus,

Thanks, looks like you've been really busy with this..

Maybe due to my lack of experience with Maven, but I'm still having problems with running in debug mode.

If I run

mvn clean install exec:java -Pdebug

From within Eclipse, then mediaplayer is started, however if I hit any breakpoints, Eclipse does not show the place in the source code because it does not know where the source code is.

I have found another way to run in debug, that is from the mediaplayer project start the class org.rpi.main/StartMe as a 'Java Application', Mediaplayer will then attempt to run, but then fails because it cant find the ohNet libs, but if I copy the libs to the com.upnp.mediaplayer/core/target/class/mediaplayer_lib/ohNet/windows/x86 directory then it will run happily. Maybe we could automate the copying of the ohNet lib files to there and maybe the plugin jars..

One question, when I run StartMe as a java app in eclipse the app.properties is refreshed each time from the pom.xml attributes. Pretty neat... do you know how that works.

Sorry I've not had much time to look at this or learn Maven, it's really busy at work at the moment.

Thanks again,

Pete.

triplem commented 10 years ago

Tried it with Eclipse. Have you installed the m2eclipse plugin? This makes your life a whole lot easier and the debugging works like a charm. I will generate a help page for this tomorrow. Basically take a look in https://github.com/triplem/MediaPlayer/blob/master/com.upnp.mediaplayer/src/site/markdown/build_instructions.md).

PeteManchester commented 10 years ago

I have the m2eclipse plugin installed and also the edit connector.

I have made some progress, I ran the command

mvn eclipse:ecipse

If i run the pom.xml as a MavenBuild and add the goals

clean install exec:java

and add all project folder to the Source lookup path, then it will run and breakpoints work. but no hot code swap though :-(

Also if I add 'default' on the Profiles, it does not pick up the default profile, which would be useful..

Hopefully your new help page might point me in the right direction.

I'm still finding it hard to see the advantage of using Maven though...

PeteManchester commented 10 years ago

Also I tried running a Plugin (Last FM).

Right mouse click on last fm moduels pom.xml

Base directory 'C:/temp/mediaplayer/tripleM/MediaPlayer-master/com.upnp.mediaplayer/plugin-lastfm'

Goals 'clean install exec:java -Pdebug'

MediaPlayer will start, but it does not load any plugins..

triplem commented 10 years ago

Hm, you seem to have a different workflow then myself.

I will take a look into the Eclipse kind of stuff tonight or tomorrow. The plugin should be loaded, but I guess I need to test it more thoroughly.

I do see the major advantage of maven vs. the current structure, that we are then independent of any IDE as well as we get some benefits eg. for site creation and releasing a new version. I have to admit, that I don't like to work without any command line tool to build my projects. This allows me to have a Continuous Integration in place and run my unit tests on each commit.

triplem commented 10 years ago

Hm, I have implemented now some trick to load the plugins from the classpath if there is no "plugins" folder, which is not the case, if run inside the IDE. One question though, can't we load the config-files (e.g. LastFM.xml) from the classpath? This would make the whole config stuff easier. What do you think?

PeteManchester commented 10 years ago

I tried that latest version and when I try to run a plugin I now get

Failed to execute goal on project LastFM-plugin: Could not resolve dependencies for project org.rpi:LastFM-plugin:jar:0.0.7-SNAPSHOT: Failed to collect dependencies for [org.rpi:mediaplayer:jar:0.0.7-SNAPSHOT (compile), de.u-mass:lastfm-java:jar:0.1.2 (compile), junit:junit:jar:4.11 (test)]: Failed to read artifact descriptor for org.rpi:mediaplayer:jar:0.0.7-SNAPSHOT: Failure to find org.rpi:mediaplayer-master:pom:0.0.7-SNAPSHOT in http://repo.jfrog.org/artifactory/third-party-snapshots was cached in the local repository, resolution will not be reattempted until the update interval of lib-snapshots has elapsed or updates are forced -> [Help 1]

Same for all plugins...

To me maven seems harder than the simple ant scripts i have in my repository,

I can run, debug, hot swap code changes, push to GitHub, compile my jar files, run all plugins or isolate certain plugins, copy jar files to my rapsberry pis, stopping the service before I copy and strating the service after I have copied, run remotely on my raspi, and I can do it all from IDE eclipse, without any need to use the command line..

The time we have spent on maven you could have spent working on mediaplayer and it's plugins.

triplem commented 10 years ago

So, you do like to stay on ANT? Fine for me as well. I still need to get a hold onto your project structure, because I couldn't build the whole project using Ant. Since I am not using Eclipse I find it very difficult to follow this one.

Basically to solve your problem just run mvn ... -U.

For me a clear separation of concerns and a clear project structure is key to a solid project. The time I invested in this migration could have spent better, but I learnt quite something about Media Player and all its components.

PeteManchester commented 10 years ago

Hi Markus,

Thanks for your work on this...

I've just merged the new Ant based version and for me it is much quicker to develop, test and deploy with.

Hopefully it is also better for you..

Cheers,

Pete.