How to deploy an Eclipse project referencing a sub-project on Heroku? - java

I'm working on a Java web project using Heroku as hosting PaaS. As IDE I'm using Eclipse and I'm trying to deploy this project.
In a previous version the project had only Maven dependencies, but now I'm referencing another project as dependency of the main web-app that doesn't reside in the main repository.
Which is the right approach to this case? Should I use a single repository?

The "right" way to do it is making the project you depend on a published artifact in a Maven repository. But that is a pain for small projects.
Here are some other options:
Build the app locally from your /.m2/repository artifacts and deploy with Heroku Maven plugin
Check the JAR file dependency in to Git as an unmanaged dependency
Make the dependency a Maven module in your main project, but also make the module dir a Git submodule. That way it's still a separate project but can be deploy to Heroku as a single app.
If you decide to do it the "right" way, I recommend deploying the artifact to bintray.com, which is a little easier to use in this kind of scenario than, say, Sonatype.

Related

Export Maven project with subproject to jar-file

I'm writing a lot of plugins for minecraft bukkit server's and I've grown tired of copy+pasting the same utility classes in my projects all over again. I decided to just put them all in a separate project and add them to my plugins via maven. I'm using IntelliJ Ultimate.
I want to have a maven project that contains all my utitily classes called e.g. UtilityAPI. Then I want to be able to create another project, which will be my bukkit plugin. In this second project I want to be able to use all the code from the first one. Also, I'd like it very much, that if I choose to build a plugin jar, maven automatically takes into account the most recent code from my API-Project.
I started working on this and started reading about maven modules and how you can use them to forge different projects together. I initially thought, that this was just what I needed, and tried to just add
<modules>
<module>UtilityAPI</module>
</modules>
However this results in my bukkit plugin project being considered a parent project, and refuses to build in a jar, but just in a (at least for me) rather useless .pom file. I'm not sure how to proceed. Do I have to create a "parent" project for my bukkit plugin project which contains the api and the plugin project as modules? And if yes, how do I generate a .jar, and not a .pom?
The dream solution would be to have the UtilityAPI project, and being able to include it in any new plugins that I might write in the future. I'd also be a fan of having a simple way to create a jar with the newest sources of my plugin in it. Is this possible, and if yes, how?
In your Maven multi-module project your plugin would have to be another module (and not the parent, which has packaging type pom). This module would then have a dependency on the API module (dependencies between modules are possible).
However, multi-module projects are usually intended for projects which are tightly coupled. That does not appear to be the case for your scenario. It sounds like the plugins have (potentially) nothing in common except for the dependency on the API project. Maybe it would be better to have the API project as separate standalone Maven project and then deploy snapshot versions of it (or install them only to your local Maven repository) and use these in your plugin projects.

How to provide dependency JARs to Jenkins for building Maven project?

I have a Maven project that uses two dependency JARs which I built in my local environment. But, when I am trying to build the Maven project (clean install), it is failing since it is unable to find those two JARs. How do I pass those two JARs?
The project is pulled from Git and then built. It is working fine unless there are dependency JARs.
The common practice today is to upload it to some artifact storage (Nexus, Artifactory, Azure Devops Feed and so on).
If you have no one, you can install those jars to your local repository (on jenkins slave or master. You must copy your jars before.) using Maven Install Plugin .
In Maven, you draw your dependencies from a Maven repository. Many jars can be drawn from MavenCentral. In a company environment, you usually run your own Nexus/Artifactory, in which you manage your artifacts (that you built) and the external dependencies. This is the best place for your JARs.

Recreating GitHub project without dependencies (Java)

I would like to use a GitHub repo inside a Script I'm writing. The Script will run inside an application which requires that the Script has minimal dependencies. By this I mean it can have a dependency on a standalone .jar or library, but not on one that has further dependencies. This is a security measure. My Script needs to have a dependency on a GitHub project, but that project also has its own dependencies. Is there any way to compress that GitHub project and its chain of dependencies into one standalone library or .jar?
I'm using IntelliJ (most recent version) if that helps. The GitHub project I need to use can be one of the following:
https://github.com/RuedigerMoeller/fast-serialization
https://github.com/EsotericSoftware/kryo
I need it to serialize and deserialize large object structures very quickly and frequently, otherwise my program doesn't operate on current data.
EDIT: So I did solve this issue, the solution was to use the Maven Shade plugin to compile an uber or fat .jar of the Maven project. This allowed me to bypass the security measure.
Having a dependency on a GitHub repo is having a source dependency (which might declare itself binaries dependencies in its own repo).
You would need to fork that repo, and transform its maven project in order to generate a fat jar (with for instance the Shade plugin).
And you would need to publish that new artifact to an artifact repository (like your own Nexus) in order for your project to depend on it.

maven project checkin in svn with local jar

I am working in a application which consume a webservice. I generated the webservice client using axis2codegen. Since it is generated code there are lot of duplicate codes exist. As per suggestion on code review we have to remove it and add it as jar. I created a jar and add to the local repository of the maven. But the problem is how can i check in the locally generateed jar to the svn, so that the user who check the project does not need to add it to the local repository manually as i did it.
Thanks in advance
Storing the .jar files in subversion isn't really the "maven way". You might want to consider setting up a corporate maven repository using something like nexus or artifactory and then deploy your .jar artifacts there instead.
Once that's done you can distribute a corporate settings.xml file pointing to this repository (or include it in each projects pom.xml file) and you can then manage your generated code like any other maven dependency.
HTH
Don't commit jar into SVN: dependency management has introduced the concept of "artifact repository" separating binaries from sources:
binary are saved into artifact repository
source are saved into source code management repository
In order to share the jar with your pears you should:
install the jar in a corporate maven repository like artifactory or nexus
add a dependency to the jar in your project pom
commit the pom into SVN
tell to your pears to check out from SVN the updated pom
You don't. In most circumstances you will use maven to deploy the project (the jar) to a repository manager (Nexus is by far the de facto for this).
Next you configure your co-workers to proxy their maven requests to yuor Nexus installation which itself "knows" about maven Central, thus providing a single point of presence for everything both from the outside world and published internally.
It's usually a good idea for another service such as Jenkins to be paired with a release plugin to execute the maven release procedure on your before, and for it to publish the artefacts too.
Here we have a long list of maven projects that our Jenkins installation builds upon noticing an SVN change. Upon the click of a button within Jenkins for the project, it can perform a complete build and release to our Nexus repository the project's newly built-and-tested artefacts.

Build play! project with maven

I am using play 1.2.4 to create a web app. It works together with some other applications which are maven projects: they are compiled and resolved (dependencies) with maven.
Now I need to modify my play app so it can also be compiled and started with maven.
Therefore I download maven (3.0.4), installed the maven modul and did everything according to https://github.com/wangyizhuo/play-maven and http://www.playframework.org/modules/maven-head/home
I manage to automatically create a pom file in my project. The problem is that the jars from the play framework are not copied into the lib-folder and when I try to execute mvn package they are missing.
Is there a way to get the maven module to work properly? If not, is there another possibility to compile and start the project from maven (i.e. intermediate ant-file that can be executed by maven?)
Many thanks in advance!
This explains it pretty well. I havnt looked at the module you are refering too, but this shows you how you can create tasks and inculde directories in your build.
Do you need to use maven to build/run it? If not it looks like there is a community contributed extension that allows you to use maven from within play.

Categories