I started using JRebel just moment ago. In my current setup launch JBoss instance from Eclipse and I use command line maven to deploy. I was wondering whether it would be anyhow possible to avoid redeployment when I need to change from test-A profile to test-B profile. Profiles are used here to set several configuration values.
If you're using JRebel, you should forget about Maven as there's no need to build the package after every change.
If profiles are used only for configurations, why not to make the changes to the configuration files directly? Depending on the nature of the configuration files these can be handled by JRebel. What are those configuration files?
You can't change profiles for already running Maven instance. But you can activate specific profiles on Maven startup using system properties.
Related
Is there a way to activate a Maven profile only if a project is (or is not) being deployed?
nexus staging plugin deploys all modules that are part of a reactor build so I want to skip certain modules (unit tests, benchmarks, etc) if the project is being deployed (to deploying them).
I know I can invoke mvn -Ddeploy deploy and activate profiles based on the deploy property but I'm hoping there is a way to avoid mentioning deploy twice.
AFAIK, you cannot do that.
There is list of possible profile activations (https://maven.apache.org/guides/introduction/introduction-to-profiles.html), stating:
A profile can be triggered/activated in several ways:
Explicitly
Through Maven settings
Based on environment variables
OS settings
Present or missing files
My guess is that profiles are evaluated before the phases/goals are even read by Maven. I tried to figure it out from https://stackoverflow.com/a/14727072/927493, but it does not say it explicitly.
It may help, though, to set <skip>true</skip> for the deploy plugin in the respective modules (the property maven.deploy.skip could also be used).
https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
We are using a maven plugin that sets version properties. These properties are used in the POM files to create the file name of the War, EJB and EAR files - and used by Jenkins.
My problem is that when I import a maven project or re-import IntelliJ uses theses file names to generate artifacts, but the artifact names become weird because the properties are not generated on import (the plugin is not run).
The outermost / top pom has these props:
${parsedVersion.majorVersion}.${parsedVersion.minorVersion}
iqe-ws${parsedVersion.majorVersion}.${parsedVersion.minorVersion}
the EAR Pom file has this prop:
iqe-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}
So the ear artifact file ends up with looking like:
iqe-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.ear
If I hard code the Props - say 2 and 1 the it becomes
iqe-2.1.ear
There are a number of ways of dealing with this.
The best is to use profiles. Put the original version of the properties are in a profile that is used on the CI box, and a set with specific values are held in a profile that is used in your local environment. Profiles are activated on the CI box using the -P profile-name switch, and in IntelliJ by selecting the appropriate profile in the maven project's window. It may even be possible to activate the correct profile automatically depending on the existence of an environment property or OS.
Alternatively, you could just override the properties using a local settings.xml file, but this would be specific to you and harder to distribute to the team and to future developers, so it's not a great solution.
Here's a link to the maven profiles documentation.
I have problem with configuration of maven project in IntelliJ. I deploy my application to JBoss, when I start JBoss server via IntelliJ, application is deployed without any additional actions, but when I try to redeploy application after some changes, IntelliJ try to make project with it's own make process, and it fails. I have to make project via maven and restart server to redeploy application. Can I somehow tell intelliJ to use maven while redeploy application? I cannot see such option in Run/Debug configuration window.
I think you are using exploded artefacts (present icon) Server, Deployment Section. Right?
There you can choose the external artefact and disable the make flag.
I always using exploded artefacts, because of the hot code deployment. So I do no need to deploy artefacts again and again.
Please be aware if there is already an artefact (e.g. foobar.war) in the same location (maven target directory), you have to change the name of the exploded artefact (e.g. foobarE.war). Idea is creating a folder named foobarE.war.
You can set several properties and configuration options in a Maven build within IntelliJ, but I haven't quite figured if you are able to specify options that are available on the command line such as --also-make or --also-make-dependents.
Is there a way to have those options used by Maven run configurations in Intellij?
You can create a run/debug configuration by right-clicking any goal in the Maven Projects view, select Create your-project[your-goal] and from there you can add any command-line parameters (such as --also-make). Your configuration will be saved and accessible from a single click on the green arrow :).
You can put --also-make into the per-project .mvn/maven.config file which sets command-line options to always apply.
In combination with IntelliJ's option to "Delegate IDE build/run actions to Maven" (which seems to be default when importing Maven projects these days), this gets building and running with the IDE's main buttons and menu items working. No more failures to resolve inter-module dependencies or failing Enforcer.
There may be undesirable side effects to always including --also-make but so far I haven't encountered them—in a multi-module project using the Reactor this way is just about always what I want, so it saves typing on the CLI too.
Side note: I still find #Bastien Jansen's answer useful for invoking other run-like Maven goals, like spring-boot:run with IDEA Community Edition which does not have the more first-class support for Spring Boot applications that Ultimate does.
I would like to setup a continuous integration environment whereby after committing the source code, it triggers a build process that checks out the code, runs tests, constructs a war file and deploys the same to jetty server such that the users/testers can access the application on the browser.
Is this possible ?
Am using maven and jetty (I am not willing to change this. I use jetty both for development and in production). For CI, I am exploring Jenkins but am open to other opensource solutions.
If possible, how do I setup the environment.
I found a maven plugin named cargo. It has everything that I needed. I added it into my pom so that I could deploy and undeploy using mvn cargo:deploy/mvn cargo:undeploy. I created a new jenkins job and added undeploy, package deploy maven goals as build steps. Everything is working perfectly.
it's definitely possible. In a previous project, the build server (teamcity) copied the war to a shared nfs location between the build server and the application server and run a little shell script that connected to the application server and restarted jetty.
We used ant inside maven to manage the deployment, I remember we used the copy and sshexec tasks.
I'm sure that there are many other solutions, but that one worked for us.
I reviewed a lot of posts like this but I want something that is maven independent. Look here, this is selfcontained runner in on hudson/jenkins. You only need 'war', even manual jetty installation is not needed. Deploy war on jetty in Jenkins or Hudson job