Intellij IDEA: Can I have custom variable's in my run configurations - intellij-idea

Usecase:
I've found no gruntjs plugin for Intellij IDEA. And I think I don't need one. If only I'd have the option to have each run/debug run ask for the parameter. For example, Rubymine has a rails generator shortcut which asks which generator to call before actually doing it. It'd like to have something like this in my grunt run configuration. Is this possible?
Thanks!

I found that although it's not possible in the Run/Debug Dialog, it is possible with External Tools: Settings -> External Tools -> Add an External Tool and then as parameter $Prompt$.

There is nothing like Eclipse's ${string_prompt} in IDEA (as far as I know). My version is 12.1.6.
Anyway, you can scroll to the very bottom of Run/Debug configuration screen and in "Before launch" section check a checkbox saying "Show this page".
From now on you'll be automatically shown configuration screen after you click Run/Debug button.

Related

Can IntelliJ's Run/Debug configurations have prompts for input?

i was wondering, if i can configure a run configuration (like executing a ruby script on a deployment server) with a prompt for parameters on starting the config. Like it does for starting rake tasks from the 'Run Rake Task...' after selecting a task.
I couldn't find anything in the run/debug config view and with a google search.
I recently found out that this feature is in fact implemented, kind of.
On the Run/Debug Configurations page there is a checkbox at the bottom called "Show this page". If you check this, everytime you want to start the config, you get a somewhat smaller version of the config page, letting you edit for example arguments and stuff.
Serves me quite well and yes, it is not fully what i need, but it does the job.
It's not supported at the moment, related requests:
IDEA-152268 User prompted values in run configuration for "VM options" and "Program arguments"
IDEA-74031 Variables in command line parameters of run configuration

How to run sbt-assembly tasks from within IntelliJ IDEA?

Is it possible to run sbt-assembly from within IntelliJ IDEA?
Also I read in the doc that one could add task within the SBT Tool window. But what I see is that it only helps you view your project not task? I cannot add any tasks there. How does the Tool window work exactly?
I have the last version of IntelliJ IDEA.
You can find the SBT plugin useful for your needs. With it, you can execute any tasks or command available in your build so sbt-assembly ones should work, too.
The plugin gives you SBT Console in which you start a sbt shell as if you were running it on the command line. The plugin gives you a more IDEA-like environment to work with the interactive console.
This answer is now out-of-date.
IntelliJ now allows you to create a run configuration for an SBT task. You create the Run Configuration by :
choosing "Edit configurations" from the "Run" menu (or the toolbar
popup)
click the "+" button to add a configuration and select
"SBT Task" as the type of configuration you want to make.
fill out the details such as the name of the task and the
working directory if necessary
You can now run the task in the same way as any other run configuration; select it in the run configuration popup in the toolbar and click the run button (or if you're one of those keyboard-only people press shift-ctrl-r and select the task from the popup that appears)
official documentation here : https://www.jetbrains.com/help/idea/2016.2/run-debug-configuration-sbt-task.html

ClearCase not working via Intellij Idea

Intellij Idea 12.1.4, Windows 7 Professional.
It seems bundled ClearCase Intellij Idea plugin not working at all. When I try to checkout(or type sth. in a file which is not checked out or hijacked) Idea says:
Cannot edit file(s): cleartool: Error: Not an object in a vob: {File path}
Actually this is an error that I am expecting because I couldn't find any ClearCase configuration that I can type my user name and password in Intellij Idea:
That's why it doesn't know where to connect and retrieve data. So question is, where are the correct configurations? Should I prepare a script for SCR text file or is Intellij Idea plugin useless?
Try first to fall back to cleartool (the ClearCase CLI -- command Line Interface), and check if your view is correctly configured.
cd /path/to/your/file
cleartool ls
That will allow you to see the config spec selection rule for that file.
And that will give you a clue for that "Not an object in a vob" error message: maybe the issue isn't in the plugin, but in your current view.
I know this is a contrite answer but the best advice really is: Don't use ClearCase.
Save your organization the headache and make the effort to switch over.
Anything will do, even svn.
Go to Settings, click on "Version Control". In the right-hand pane you need to add a Directory/VCS configuration tuple. Do this by pressing the green PLUS (+) icon.
Select "Project" and select "Clearcase" as Source Control tool. You should now have a context menu item "Clearcase" in your IDE and can check out files by right-clicking on the file. One small disadvantage in my Intellij 12.1.6 is that he only sees the change sets (Activities) that were created using Clearcase Explorer... (only loaded at startup time of Intellij). So you cannot add new change sets that will be propagated to Clearcase.

IntelliJ: Mapping running/debugging specific configurations to toolbar

Googling, searching this site and random experimentation yielded nothing, so here goes.
I'm working on a project containing different Maven projects where several of them need to run in order for the system to work. (Clients, servers, etc.) Launching them all individually is kind of inconvenient, but as this question suggests, there's no way to group them into a single configuration (nor does the situation seem to have changed since that answer).
Instead, I'm now wondering if it's possible to map running/debugging specific configurations to the toolbar, i.e. have a "Run Project 1" button, a "Debug Project 3-C" button, and so on instead of having to do the three-step process of opening the list, choosing a configuration and clicking run/debug for each needed component.
Does anyone know of a way to accomplish this?
You can't have multiple configurations at the toolbar, but I can suggest a better alternative for running multiple configurations at once.
In IDEA 12 it's possible to run another configuration in the Before launch section. So you just add all the other configurations you want to be started with the current one in Before launch steps, then run single configuration and get all of them launched. Note that you can run Maven goals from the same configuration:
As you've noted, it will not work if the configuration continues to run as it will wait for the command to finish.
I'm afraid there is no easier way to do it right now except probably using the keyboard shortcut for the run popup menu.
Here are the issues you should vote for:
IDEA-94341 Launch Multiple "Run/Debug Configurations" At Once
IDEA-69968 Add option to assign keyboard shortcut to Run/Debug configurations
IDEA-75078 Make it possible to create toolbar action for running specific run configurations

In Intellij, right click on a test does not present a "Run" option

In IntelliJ when I right click on a test I dont see a "Run ClassX or MethodY" anymore. In fact there is no "run" window and when I right click I cannot run any class.
It was all working fine about 3 hours ago so I am not quite sure what has changed.
IntelliJ 10.5.1 (Licensed and NOT community edition)
Java 1.6.0_24
This happens for all projects.
Update 1
I installed IDEA 11 and imported settings from 10 and then saw that it was not a free upgrade close IDEA 11 and started using IDEA 10. I am fairly certain things stopped working from that point but not sure. Is that a problem? Can I somehow delete IntelliJ configuration directory somehow and restart?
Adding a screenshot when I don't get Run option on right click:
My problem was that my test class wasn't public. I needed:
public class MyTest {
#Test
public void testMethod() {
instead of:
class MyTest {
#Test
void testMethod() {
If your project is a maven project then you can just right-click on the pom.xml file and select "add as Maven project".
This approach worked for me. (green plus third from the bottom)
I had the same problem. To fix it, I had to ensure that my class had a proper main method:
public static void main(String[] args) {
}
Every keyword in the above statement is critical. If you omit one, IntelliJ wont' recognize it. Easy-to-forget keywords are static, void, and the String[] args argument.
I had forgotten the arguments in mine ;-)
Also make sure your source code is inside a src folder which is marked as such by IntelliJ.
In my case, the cause was disabled JUnit plugin. (File — Settings — Plugins — JUnit, check, OK)
If you're using JUnit 5 (Jupiter), this happens when you use the old #Test annotation from JUnit 4. Just replace
import org.junit.Test;
with
import org.junit.jupiter.api.Test;
and IntelliJ should show the "Run" button again.
Ok after tremendous amount of eyeballing I located a {HOME}/.java directory which seemed to contain some Jetbrains related preferences. I deleted that directory plus {HOME}/.IntelliJ* directories. Then deleted all my intellij installations and downloaded it again from scratch and it now works fine..
Sigh....
Disabling gradle plugin solved the issue for me (community edition 2018.2)
In my case i right clicked the src folder and went to -> mark directory as -> sources root.
I had the same problem. I solve it by
File -> Invalidate Caches / Restart
right click on the top pom.xml -> Maven -> reimport
There should be no need to delete any configuration files.
I found that I used to have the Run option in the context menu to select either run tests or run Scala tests, etc. After I had selected an option for the first time, my options were no longer there.
I was able to resolve this issue and select the type of tests I wanted for that folder by creating a Run/Debug configuration following the instructions found in the documentation here...
https://www.jetbrains.com/help/idea/2016.1/creating-run-debug-configuration-for-tests.html?origin=old_help
As i had the same issue , i could clearly See that #Test is not providing any hint when i press control key and hover , and the same was confirmed as External Libraries was not having Gradle Dependencies added so i had to update the project as gradle project suggested by a pop up when you start Intellij.
I could resolve the issue by disabling the Gradle plugin from the Plugin menu and restart.
If the project is already added as a Maven one, unlink it.
right click on the project -> Maven -> Unlink Maven Projects
Then link it again:
right click on pom.xml -> + Add as Maven Project
I've just had the same problem and solved it in the following way.
Go to your $USER/$INTELLIJ directory e.g. $USER/.IdeaC2018.3 then find config/plugins. Rename the plugins directory and restart IntelliJ.
My guess is that the problem was caused when I upgraded IntelliJ and incompatibilities with the cucumber plugin.
For me this happened after updating Idea, and then updating all Plugins. Apparently Idea had not restarted yet. Going to File -> Settings -> Plugins and clicking 'Restart Idea' solved the problem
if you can see the play button in left side of the main function then click right click and press run.
in my case, I did not have an output folder.
file -> project structure -> under 'project' tab there's 'Project compiler output' -> define your folder.
Unfortunately, none of these worked for me. I had to
'File' -> "Invalidate Caches / Restart"
Click on pom.xml file, and then 'maven' -> "Generate Sources"
Search for pom.xml file --> Right Click on pom.xml --> Click on Add as Maven Project.
You should get a pop-up, saying downloading Mavin Plugin.
Wait till it gets completed. It takes some time depending on the number of content in pom.xml.
In the below screenshot, "BackendApp.java" is Driver Java file that contains
public static void main(String[] args){}
Right Click on such driver java file and you see Run option in green color.
I had this problem with a Kotlin project. Following action solved it:
right click on test folder -> select Mark Directory as -> choose Test Sources Root
So I had this problem on pycharm and the problem was that there was already a run configuration (in the dropdown next to the play button) that had the name of the file. When i deleted that run configuration it would create a new one that was correct.
I had the same problem and I tried all the above solutions nothing worked for me but after I install TestNG plugin it's started working since there are some TestNG annotations used in my unit tests
I had the same problem on my Intellij 2019.3 after that I updated from 2019.2.4. I thought that the problem came from the updated first, but the rollback didn't fix, so I tried de solution above e the problem was fixed. After configuring all my projects from scratch the problem get back, so I started to check everything I did. I discovered that an old project from Eclipse that uses files .launch to run and need some plugins to be able to execute on Intellij was causing the problem, after disable the following plugins the test option return.
In my case, my project is using Bazel.
The solution was to sync Bazel from Bazel plugin.
Since this is a top Google result when trying to figure out how to run a Scala project, and since for some reason IntelliJ (I'm on 2020.1.2) doesn't automatically create a run configuration for a Scala project (in contrary to a Java project), it's worth laying out the basics for future readers:
Click on "Edit Configuration" on the top right of the screen.
Inside the opened window, click the + button its top left.
Choose "Application".
Now, let's go through the required fields:
in the "Name" field, enter a name for this configuration, e.g. "run".
in the "Main Class" field, enter your main class name.
Alternatively, use the ... button to the left: inside the window that opens, click the "Project" tab, navigate to your main class, pick it and click "ok".
Note: If your main class doesn't have a main method, IntelliJ would show an alert. see listing 9 below.
Make sure the value in "Working Directory" field is correct (it should be the project folder).
in "Use classpath of module", select your module (see project vs module in IntelliJ)
That's it for configuring. Click "Apply", and close the window. Here's an example final result:
Note that my Main class is part of a package named Demo, but having a package is not necessary.
Inside the main class, make sure there's a main method.
See #Josiah Yoder answer for java, and for Scala it's:
def main(args: Array[String]): Unit = {
}
That's it. You should now have the green run and debug buttons enabled.
Seems there are version conflicts between plugins and IDEA itself that commonly break this functionality. Many of the solution here indicate people manually trying to identify the plug in, I found that to be impossible. So here is a generic way, without having to uninstall IDEA as one solution proposed:
File > Settings > Plugins > gear icon > disable all downloaded plugins
This fixed it for me.
Make sure the method is not static! JUnit only allows #Test before instance methods but Intellij doesn't complain even if you use #Test above a static method.