I've configured various execution and test configurations in my Java IntelliJ project. Is it possible to execute IntelliJ on a given project and configuration from the command line?
Summary
You will need to define a command line build project to run your tests from the command line, as IntelliJ (or any graphical IDE) does not provide tools to do so.
Details for building running tests using Gradle
In the following directions I picked Gradle as command line build language, though some use Ant, or Maven as possible alternatives. The gradle syntax is based on Groovy, which is a JDK-based scripting language.
A sample configuration for a basic java project is here: http://www.vogella.com/tutorials/Gradle/article.html
Once your Gradle project is setup, you can run 'gw test' from command line.
I highly suggest to install gradle wrapper called 'gdub' from here: https://github.com/dougborg/gdub -- this will save typing ./gradlew all the time.
Hope this helps!
Related
I'm trying to build a TypeScript project with JSweet. After the transpilation, I want to run a script in any language to move some files around; specifically files that are already in TypeScript that don't need transpilation. I wrote a Groovy script that does just that but I can't make it run after the generate-sources instructions for JSweet.
Here's my pom.xml file: https://pastebin.com/932r9cWw
I am far from a Maven expert. I think the script shows that I'm trying to run the script scripts/addJsScripts.groovy after the transpilation, but I'm clearly doing something very wrong. The goals available to Maven Invoker plugin don't match the goals of the JSweet transpiler at all.
Is there a way to do what I'm trying to do?
There are plenty of ways to achieve this, but this is more a Maven issue than a JSweet one.
I suggest you use the exec-maven-plugin, as explained here: I want to execute shell commands from Maven's pom.xml
I would like to add my own commands to delete a specific folder in the mvn repository whenever I run a maven command.
For using maven through the command prompt, this is quite easy since we just update apache-maven-3.5.3\bin\mvn.cmd .
However, I noticed that when we run mvn from intelliJ Maven projects Tool Window, the command run is the following:
C:\mbakOrg\Oracle\JDK\jdk1.8.0_60\bin\java -Dmaven.multiModuleProjectDirectory=
C:\mbakOrg\_CODE\MNE_ARCHIT_GIT\_REPOS\sg-template-store -Dmaven.home=C:\mbakOrg\build\apache-maven-3.5.3 -
Dclassworlds.conf=C:\mbakOrg\build\apache-maven-3.5.3\bin\m2.conf "-javaagent:C:\mbakOrg\devel\JetBrains\IntelliJ IDEA
2017.1.3\lib\idea_rt.jar=42633:C:\mbakOrg\devel\JetBrains\IntelliJ IDEA 2017.1.3\bin" -Dfile.encoding=UTF-8 -classpath
C:\mbakOrg\build\apache-maven-3.5.3\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version=2017.1.3 clean install
So how will I add a command that will run every time?
Since maven in InteliJis using a custom way to run maven.
Explanation
My problem is basically that the mvn -U command does not properly pull the newest code all the time. Additionally, we are all using a snapshot of a parent project that is being updated quite often to fix issues.
I would strongly discourage modification of mvn.cmd. Even if you figure out how to do it in command line, and in InteliJ, then think about moving to some kind of Continuous Integration framework, like Jenkins for example, which will use default mvn.cmd?
If there is no possibility to achieve what you want with existing Maven tools, I would recommend writing own Maven plugin, (see this tutorial), and put required functionality there. It will guarantee, that this particular piece of code will be executed in all the environments, and this is the way to make sure, that the command will be launched every time.
This is what i have done till now:
I have API automation Script in maven using testng, Following is the structure of project
2.Now i first tried to run testng.xml using command-line with following command.
java -cp ".;C:\Users\A622965\.m2\repository\org\testng\testng\6.8\testng-6.8.jar" org.testng.TestNG testng.xml
3.But throws following error:
Error: Could not find or load main class org.testng.TestNG
Not able to figure out the issue after watching lot of tutorials.
I am looking to batch process the script using Task Schedular in Windows
Remember that Maven is a build tool, so every single operation which requires the classpath must be done through Maven, wether if you want to execute it from the command line or from some GUI.
So, in your case you will find useful the Maven command line tool:
mvn <phases>
In your case:
mvn test
But remember to include first in the pom.xml the testng library dependency, and also to properly configure the surefire plugin.
You need to build path for testng
Right click-->Build -->Libraries Tab-->Add External jar-->Then restart--it will work...
I've been learning Maven and absolutely love it, it's an incredible tool. I'm currently running mvn clean, build, compile, package etc from terminal. This works fine but I figure I could do all this from the IDE. However, using -clean as a command line arg in the configuration settings throws an error.
The current command is simply idea:idea. When this runs it appears to be building the project and adding resources but no mention of clean / verify etc.
I've searched various jet brains pages but can't find a commandline list. Ideally I'd like to be able to set up a couple of different configurations, these mimicking the cones that I'd call from the terminal.
thanks for any help
In intellij you have Maven Projects Tool Window which you can use to run any maven build phase or plugin goals, you can also create run configurations from them (just right click and select create).
You can also create maven run configurations by yourself using Run/Debug Configurations dialog. There should be maven type available on the list.
However, using -clean as a command line arg in the configuration settings throws an error.
You should pass just clean as command line argument.
You can read more about how to call maven for example from Maven: The Complete Reference
I followed Storm Starter instructions and imported Twitter Storm in IntelliJ. For sake of testing I edited ExclaimationToplogy a bit and used following Maven command to build and run it:
mvn -f m2-pom.xml compile exec:java -Dstorm.topology=storm.starter.ExclamationTopology
But I am more interested to build and run within IDE rather than from command line. What actions do I need to perform?
Thanks
Follow the steps in storm-starter's: Using storm-starter with IntelliJ IDEA
Open Maven's pom.xml file and remove <scope>provided</scope> line from storm dependency. This enables IntelliJ to compile storm dependency on build.
Go to /src/jvm/storm/starter/, right click on ExclamationTopology file and Run 'ExclamationTop....main()'
From within IntelliJ, if you get Clojure related compiler errors involving LocalCluster then .... do a mvn clean install -DskipTests from the command line on the same project first. Then do a 'Rebuild Project' from within IntelliJ. Life is full of mysteries :-).
You need to also ensure that the storm-core is not in provided scope for storm-starter.