How to avoid unneeded recompilation from IntelliJ Idea 13 when it runs a maven vaadin project created in the command line - maven

I have created a maven vaadin project using the command line like this:
mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.1.9
Then I change into the folder of the application and I give at the command line the following :
mvn install
After waiting for the application to compile, I open it using IntelliJ Idea (by opening the pom.xml file), I add Tomcat Server and I press run.
Then the IntelliJ Ide recompiles the application again.
Is there any way I can avoid this second compilation?
Thank you.

You should have tomcat configured as a server, and configure your module(s) to deploy at server startup. On the run configuration you will see a list of things to do before launch. It will probably say Make -- you can remove this if you need to.
However, you probably should allow idea to do this for you and really stop doing it on the command line. Idea can handle more complex build patterns for you. You should trust it.

Related

Run a spring-boot project but pages of another project show up

The keyword is too verbose to help me find anything useful. Please pardon me if it's a stupid question.
I have two spring-boot projects, A and B, in the same directory. I run
mvn clean
mvn compile
mvn package
mvn spring-boot:run
in the directory of project A and want to run A. However, the pages of project B shows up (both of them use localhost:8080).
I tried the following but none worked:
Moved and renamed A to another directory and ran all the above commends again;
Clean brower cache or open in incog window;
Remove .m2 folder;
Reboot my laptop;
Run with IDE, mvn spring-boot:run, and java -jar target/ProjectA.jar;
Invalidate Cache/Restart in IntelliJ.
Also:
If I break Project A (make it fail to compile), mvn compile will fail;
If I break Project B, running A will still give me B;
If I change the contents of html files in B, it won't change the showing pages;
If I debug the project A, it will hit the main function in #SpringBootApplication;
Everything is running on Win10, no container or VM.
It seems I am running Project A, but it has neither MvcConfig nor html templates, where are those pages from? I did a thorough search for page contents, but the project directory of A didn't contain anything like that. So it must from somewhere else.
Github: https://github.com/PhoenixPan/finishthem-api-server
(doesn't have any visible html page)
Hope someone could explain why this is happening and how should I prevent it... Thanks.
Have you tried running your project A from your IDE as a simple java application? You can run a Spring Boot application from your IDE as a simple Java application. However, you first need to import your project. Import steps vary depending on your IDE and build system. Most IDEs can import Maven projects directly. For example, Eclipse users can select Import…​ → Existing Maven Projects from the File menu.

problems running state machine examples

Congratulations on the spring state machine, I found it yesterday and have been trying it out, specifically the turnstile example running in STS. I found it very easy and intuitive to build a FSM.
Because spring shell doesn't work well in STS I tracked down the instructions to run the examples from the command line in the reference doc,
"java -jar
spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar"
,
but running it got an error
"no main manifest attribute, in spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar".
Although not even a novice in using gradle, I tried fixing this by adding this line to build.gradle in the jar section
"manifest.attributes['Main-Class'] = 'demo.turnstile.Application'"
(which doesn't handle the various sub-projects I know) but got this error
"NoClassDefFoundError: org/springframework/shell/Bootstrap".
If it is possible to run the samples from gradle, could you include them in the reference document? I tried running the samples using
gradle run
but it there was no interaction with the shell scripts.
Samples are designed to be run as executable jar and with shell so that you can interact without a need to recompile with every change. Your error indicates that you didn't build that sample jar as mentioned in docs.
./gradlew clean build -x test
This will automatically use spring boot plugin which will add the necessary jar manifest headers to jar meta info to make it a true executable jar. Essentially every every sample is a spring boot app.
Building SM sample projects in Windows Environment:
Open Command prompt (windows key + r -->cmd-->Enter), Change directory to project root folder spring-statemachine-master (Inside the Extracted folder).
Run gradlew install to get all spring dependencies copied to local machine.
Run gradlew clean build -x test to get the spring shell jars built. Courtesy Janne
These steps should ideally get all .jar built, look into \build\libs folder of respective sample project for jar files.
Run the like any other java jar file java -jar [jar-file-name.jar] (make sure to be change directory to jar file directory location).
One more thing where I was stuck was, How to give events to SM:
It's like this sm event EVENT_NAME_AS_DEFINED_IN_CLASS. Ref
E.g.: sm event RINSE --> to washer project

Share Maven run configurations with other developers using Intellij IDEA

We have the following project setup: Maven, Eclipse, Subversion. Eclipse Launch configurations are in a separate docs folder next to the pom.xml. The launch configurations run something like mvn clean install -Pdev or mvn tomee:run -pl something-ear
The good thing is that a shared run configuration is picked up by the IDE and shown in the External Tools run commands. This way, every developer that checks out this project immediately has access to run the build.
We would like to have something similar using IntelliJ IDEA, but I haven't found a good equivalent. What I have considered so far:
Share run scripts
My first idea was to replace the launch configurations with run scripts. I just could not figure out how to have those run scripts run inside IntelliJ IDEA just the way a Maven goal would be executed.
Share IDEA project configuration
The IDEA project configuration (specifically .idea/runConfigurations) inside the checked out directory is not a good solution. We have (speaking one IDEA project with different IDEA modules depending on the task at hand: as a developer you might need multiple IDEA modules (and sub-modules) in the same IDEA project
An IDEA project consisting of the following modules is not something unusal
projectA/trunk
projectB/tags/1.2
projectC/branches/some-change
My preferred solution would remove all IDE-specific configuration from the repository and have some kind of run definitions either in the project folder or a folder next to the pom.xml that a developer can run from the command line or from her IDE of choice.
The optimal solution would let me define something like this in the pom:
<runConfigs>
<default>clean install</default>
<container>tomee:run -pl something-ear</container>
</runConfigs>
This configuration would then be picked up by the IDE and provided as a run or launch configuration to the developer.
Any ideas or suggestions?
Thank you very much!
My current approach is a hybrid solution:
No configuration in the separate modules
One IDEA project configuration with run configurations managed in VCS
The .idea/runConfigurations directory is versioned separately from the project sources. It contains commands with a working directory set relative to the PROJECT_DIR:
<MavenRunnerParameters>
…
<option name="workingDirPath" value="$PROJECT_DIR$/path/to/submodule" />
</MavenRunnerParameters>
When setting up a new project, the developer also checks out this folder and has a set of pre-configured launch configurations for all projects. The downsides are
All launch configurations are managed centrally instead of with the module
The IDEA project directory has a fixed location relative to the modules. If you set up another project, you will have to change the run configurations
The setup does not clearly state how changes to the launch configurations are shared with other developers

no executable code found at line intellij 14

I am unable to debug remote applications due to: No executable code at line
I am running ultimate edition of Intellij, version 14.0.3. My application is running inside tomcat 8 and i'm building it from the command line using Maven. This problem appeared after i switched from the community edition to the ultimate edition.
Project sources are the same and I am able to connect to tomcat for remote debugging. The only issue is that all my breakpoints are invalidated.
Please advice on how to fix this issue.
Cheers.
Remove all IDEA related project files and open the project by the .pom file.
I've had the same problem. Simply compile the directory that the class resides, and the debugger will pick up the break point.
I had the same problem and I implemented a similar solution.
Remove all IDEA related project files and open the project by the .pom file.
I use Gradle for my projecto, so i removed the project from intellij and then reimported it.
I hope others could read it and helps them
if you are developing an Atlassian plug-in and connected to the server via remote debug, run atlas-package to sync deployed plug-in and your source code.
If you are running a maven project execute the following commands in cmd prompt.
mvn clean install
mvn compile
This will resolve the problem.
The solution that worked for me is much more embarrassing. I put the breakpoint on the wrong line.
You see two breakpoints, first one is working and the second one is complaining about "no executable code ...".
It turns out there really is no executable code, just a string.

deploy maven application in JBoss not work

I'm developing my first maven application and now i have this trouble, i performed the following commands
mvn compile
mvn package
mvn jboss-as-deploy
the deploy process ends without errors but in my JBOSS_HOME\standalone\deployments i don't find the .war
why?
Try to set targetDir option (maybe the default is overriden in your environoment?). See http://docs.jboss.org/jbossas/7/plugins/maven/latest/deploy-mojo.html.
The $JBOSS_HOME/standalone/deployments directory is not where deployments are stored. If you look in that directory there is a README file that explains it's what the directory is used for.
The jboss-as-maven-plugin uses the deployment API's to deploy the content to the server. This generally ends up in $JBOSS_HOME/standalone/data/content for a standalone server. Though you really shouldn't be doing anything with files in that directory.

Resources