Maven dump file on ftp server when deploying - java

My Maven builds a ready zipped package that just has to be uploaded to a ftp server.
Is there a plugin for this task? It should start when I choose the deploy goal.
I see some ftp support for the real way Maven deploys files, but nothing for a custom ftp upload.

What do you mean by a "custom" upload?
The deploy plugin doco describes how to normally deploy a build artifact using ftp.

Related

Deploying Java application on remote server using Maven

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.
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.

How to transfer file to server using maven

Once maven creates a WAR file (with mvn package) I would like to somehow transfer the war file onto another server and then execute a command on the server to deploy the war to tomcat. I am connected to the destination Windows 2008 Server via VPN. I can also ping the destination server while vpn'd in from my local machine.
Is there a way to do this transfer of the war from my local computer to windows 2008 server? Would I need to install something additionally on the windows server?
This blog entry details how to use the Maven Tomcat plugin to do this.
Issue “mvn tomcat:deploy” to package your project in a WAR file, and
deploy it to Tomcat server. To verify it, just access to the Tomcat’s
manager page and make sure “/mkyongWebApp” path is existed.
Basically you configure Tomcat to accept a remote deployment, configure your settings.xml with your Tomcat credentials, and set up the Tomcat Maven plugin with the hostname/port etc of your Tomcat server (phew!)
There are many ways, but none of them are ideal. I would personally discourage the use of Maven as a deployment or "devops" tool. If you really need to do this there's a good chance that your requirements are going to evolve and become more complicated as your application develops. Why not just start with CFEngine, Chef, Puppet, or other tools?
Warning aside, you could do the following:
Deploy with scp - The Maven Deploy Plugin can scp a file to a server. This overrides the real purpose of a deployment in Maven, but it will work. (Again the downside here is that you'll be overriding the real way that Maven was designed to work) For this to work you may need to explicitly add the SCP wagon provider, it used to be present by default, but it was removed.
Use Cargo to manipulate whatever server you use - http://cargo.codehaus.org/Maven2+plugin

connect to teamcity from java and download a build

I've been googling how to connect to a TeamCity server and download a specific .war file. No luck.
I'm writing an application that needs to connect to TeamCity, download a war file, upload it to a server and some other stuff.
I can't figure out the TeamCity thing. Any suggestions?
You can do this with artifacts in TeamCity. For example you add the following artifact path to your configuration: src\YourProject\bin\Release\* => YourBuild.zip
This will pack all files located in this folder in the zip file. See this blog post for more examples.
The zip file itself is then available for download e.g. http://localhost:8080/repository/download/bt6/180:id/YourBuild.zip
To get the proper IDs (here bt6 and 180) for your download link you can use TeamCity's REST API.
Here is the official documentation how to download build artifacts from TeamCity server.
Commons HTTP client is known to work well. You need to authorize or to enable public access to your artifacts (see more on this).
Hope this helps,
KIR

How do I build .war file in Eclipse for Glassfish server

I have web application written in java using Eclipse. It has just one servlet that does some file manipulations. How do I build war file so I can easily deploy it to my remote server.
Right-click on the project, select 'Export...', then choose web -> WAR.
You should be able to use Maven to package a WAR to deploy to your remote server. It looks a little daunting, but once you create your own WAR file you should be ok, check out:
http://maven.apache.org/plugins/maven-war-plugin/usage.html
In fact you should be able to manage deployment using the Maven Glassfish plugin here:
https://maven-glassfish-plugin.dev.java.net/
That will allow you to start,stop,deploy,undeploy etc... your web app. Example here:
https://maven-glassfish-plugin.dev.java.net/examples/complete.html
Just for the record,
The default build artifact for a
NetBeans Web project is a war
The default build artifact for a simple
Java project is a jar

Can we upload a file on ftp server outside its default directory?

I have created a sample Java Web Application in spring boot and inside Pom.xml I am using Maven Wagon to ftp my project's war file on FTP server.
But, Maven Wagon uploads war file into default folder of FTP server. I want Maven Wagon to uplad the war file into some other directory on FTP server for e.g Tomcat Web-apps directory.
Please tell if it is possible. If yes then what changes need to make in Maven Wagon configuration
Don't have/know Maven Wagon, but code that takes an FTP URL will usually take the folder/file name as part of the URL.
Since the file name is define elsewhere, specify the target folder in the URL:
<url>ftps://secure.example.com/put/my/file/here</url>

Categories

Resources