1

I am writing a Java application using Maven. I have to deploy the application on a remote powerful server to run experiments. The simplest way I figured out to do this was to build a jar-with-dependencies using Maven shading plugin and then copy the uber-jar to the remote server. However the jar is big, 100+ MB, and it takes some time to send it through our network. This is redundant because most of the jar consist of heavy dependencies (Scala, Spark, Jetty) and only a tiny portion of it changes when we change our code.

Can I use Maven to install the dependencies on the remote server and then only send the much smaller jar with no dependencies to the server?

I have SSH connection to the server and I can use the SCP plugin.

Little Bobby Tables
  • 5,261
  • 2
  • 39
  • 49
  • 1
    If a server is powerful why not just build it there? – Yegor Chumakov May 17 '16 at 11:50
  • You could make an uberjar of "everything else", send it once, then add your "changeable" stuff to the class path when you run it on the remote server... see this: http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath – Mainguy May 17 '16 at 12:12
  • @YegorChumakov then I need to send the code to the server and it is a redundant step, I don't use it as a development machine, and I don't want to push to get git every time I change the code – Little Bobby Tables May 17 '16 at 14:07

1 Answers1

0

You mention Jetty in your question so I am assuming your application server is Jetty. I would try and upload the common library jars to the server and then including them in the jetty class path. This will be a one time task. Maybe this will help: How do I place jars in jetty/lib on the jetty classpath?.

After this you can use maven to built a "thin" war/jar which you can upload and deploy.

Community
  • 1
  • 1
chrisl08
  • 1,658
  • 1
  • 15
  • 24
  • Jetty is mentioned as an example. I also have a case in which I do not use jetty – Little Bobby Tables May 17 '16 at 14:05
  • The solution still applies for any application server. Upload your third party jars to your server's lib directory. And use maven to built a "thin" war/jar which you can upload and deploy. – chrisl08 May 17 '16 at 14:33