I have Jenkinsfile it's written in Groovy, but file name doesn't have approprite extension: .groovy. How can I tell IDEA to check groovy syntax of this file?
Update:
Also I interested in the same question about GoLand IDE
From the project sidebar, right-click the file and choose "Associate with File Type". Then just select Groovy from the menu, and you're all set.
GoLand does not support Groovy so this will not be possible there.
If you add following header comment in the beginning of your Jenkinsfile:
#!groovy
IntelliJ IDEA will automatically recognize this file as a Groovy source file. It should work for other editors and IDEs as well.
Related
A little intro:
I work on a project with legacy codebase witch uses internal xml based descriptors with specific file extensions (about may be 10 extensions).
Let it be *.desc, *.check etc.
To have code highlighting for such a files I can configure Idea to consider these types of files as XML.
It's available through:
Preferences / Editor / File types
And then add all custom extensions to 'Recognized file types': 'XML'
Our project uses gradle as build tool
and my question is:
Is it possible to make same configuration via dsl of gadle 'idea' plugin?
The short answer is: No.
One could create a custom Gradle task that will modify IDE file type preferences XML file in the config directory. While it's possible to run such task automatically on the project refresh in IntelliJ IDEA, it will most likely not work since you can't modify IDE configuration when IDE is running (the changes will be reverted). So, you will have to run it from the command line, outside of IntelliJ IDEA when IDE is not running.
It's probably not what you want, but if documented, can be used by the team as the manual step to make this configuration change easier.
Using gradle idea is not recommended anyway.
A better way might be to provide your own IDE plug-in that will associate these file extensions with XML file type and instruct the team to install this plug-in.
I have installed the cucumber-java and gherkin plugins in IntelliJ IDEA but when I create a .feature file it is not recognized as a feature file. I did restart IntelliJ and have checked to make sure the plugins are enabled in the plugins settings window.feature file in IntelliJ
If you have Substeps IntelliJ Plugin enabled then that might be the issue. you will need to remove and restart.
Check Settings->Editor->File Types. Verify that Cucumber Scenario is set to a Registered Pattern of *.feature.
Check File -> Settings -> Editor -> File Types and click on the Text file type. Look at the Registered Patterns section below and verify that the file you're trying to create is not in the list of recognized patterns for Text file types.
This might happen if you created the file without initially giving it the .feature extension. If you do that and then try to add the extension afterwards IntelliJ will probably still think it's a text file and will not treat it as a feature file. This was the fix for me.
If you're seeing IntelliJ recognizing your intended feature file as some other type of file then check the recognized patterns for that file type and verify again that the file you're trying to create is NOT in that list.
See http://www.gisremotesensing.com/2014/11/solution-intellij-not-recognizing.html
For some setups, this is only half the story. Once, you have removed the old file type; now follow the steps:
Select "Cucumber scenario" in the "Recognized file types"
In the "Registered patterns" box click the "+" and type "*.feature"
Now you are all set. The feature files will be back to normal.
Navigate to the settings from File option at menu then -> Editor -> File Types --> Select Cucumber scenario (Recognized file types )
observe that if Registered patterns has *.feature if not then click on + icon and add *.feature in Registered patterns.
Apply changes and save.
It solved my problem of .feature file. Thanks!
The root cause for this problem is Cucumber-Java plugin looking for BDD annotations that are imported from the package cucumber.api.java.en.Given (depricated) in StepDefinitions file. If the StepDefinitions file consists of BDD annotations from the package io.cucumber.java.en.Given the feature file won't recognize/highlight those steps. This issue is nowhere related to Intellij Version.
Temporary solution
Change your import statement in your StepDefinitions file from import io.cucumber.java.en.Given; to import cucumber.api.java.en.Given; Apply the same to When, Then and But unless if you don't mind using deprecated methods ;)
Note
If you use the info.cukesdependency you won't have any problem with the cucumber-java plugin
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
You need to use the Temporary Solution if you have the io.cucumber dependency
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.6.0</version>
</dependency>
I had the same issue:
Substeps not enabled in my IDE... soooo:
Check if you have garbage .feature of former Files in your File Types patterns. Somehow i had two feature files under the text-Format File Type... that caused new feature files not being recognized as such on creation.
I think this happens if you do not mark files as feature-files on creation and do this afterwards with refactoring. Then intelliJ saves the pattern of the feature-file under text-type...
InjelliJ IDEA 2021.1.2
I had my feature filename listed under Settings > Editor > File Types > Auto-Detect file type by content. Removed it and its all working.
I had a typo in the file name extension. Easy to miss.
Verify that the feature file name ends with .feature.
For me it was even worse. The .feature extension was assigned to text. Which was odd as previously created .feature files remained real feature files. Yet newly created feature files were seen as plain text. So do check all relevant file types as intelIj does strange things with this.
In my case when I tried to add .feature file, a prompt came up and I added the file as text. Then Intellij automatically suggested that it found plugins(Gherkin plugin) matching .feature file. After installing Gherkin plugin , IntelliJ automatically formatted the file with Gherkin format
Using IntelliJ IDEA 2022.1.2 (Ultimate Edition)
A quite quick manual patch is to right click on the .feature file you want to be recognised. A dropdown menu should appear. Click on the "Override File Type" option. Then, scroll down until you find "Gherkin", and select it.
I have some xml files within the source folder along with the java files.
Intellij Idea is not copying them to the target folder.
I want those xml files to be along with the classes in the target.
Eclipse does this fine.
Can anyone please tell how to achieve this in Intellij Idea?
If, like me, the other answer didn't solve your problem -
If IDEA thinks your project is a Maven module (or once was), and it isn't, it'll behave like this. You can fix this by closing the project, editing the .iml file to remove the isMavenModule property, reopening, and rebuilding:
<moduleorg.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true"type="JAVA_MODULE" version="4">
In its default configuration, IDEA should copy any xml file that are in a source directory into the target directory. Other build tools may not. So this answer is assuming you are making the project via IDEA's internal build/make. If using maven (or gradle), you should place your resources in src/main/resources and not src/main/java as Engineer Dollery mentions in his/her comment.
If you are using the IDEA builds and it is still not copying them over, there is a setting you can check. Go into Settings > Build, Execution, Development > Compiler. On the Compiler settings dialog at the top is a "Resource Patterns" text field. This will define what files IDEA will and will not copy over. The default entry is:
!?*.java
!?*.form
!?*.class
!?*.groovy
!?*.scala
!?*.flex
!?*.kt
!?*.clj
!?*.aj
It is just a set of negation patterns of things not to copy over. So XML files should be copied. Check this setting and see if there is something in it to prevent xml files from being copied.
I am attempting to use an external diff tool (Beyond Compare) to compare folders in Intellij IDEA 13 (EAP Build #IU-133.471).
Settings
My Intellij IDEA settings are as follows:
Documentation
Relevant documentation for BC : here and here
Intellij IDEA's doc on the subject : here
Herein Lies the Rub
And here is what happens when I select two directories and press Ctrl + D (the shortcut to Compare Directories) :
The same works fine when comparing files:
I have attempted using the current stable version of both Beyond Compare (v3.0) as well as Intellij to no avail. I have had no joy after appending the parameters %1 %2 etc. to the Path to Executable either.
Can you think of what I might be missing ? Have you used an external diff tool to compare folders in Intellij IDEA ?
Am planning to ask this question in the Intellij forums and/or raise a Support Ticket with them after waiting to hear back from the SO community.
Thanks!
Update
Question now present in the Intellij IDEA forums too : http://devnet.jetbrains.com/message/5506980
This seems to be a bug in Intellij.
See this.
Update (9-Nov-2015)
I am using Intellij Idea v 14.1.5 and can confirm that this bug has been fixed.
I really like the IntelliJ plugin "Compare Directories" I have used it since IntelliJ 13.
Here's the plugin's home page: http://plugins.jetbrains.com/plugin/?idea&id=113
Once installed, the tool can be used by right clicking a directory or package and then setting the directory structure to compare against. This tool includes directory and file level comparisons.
I just switched from Eclipse to IntelliJ and noticed that when I use "Reformat code" feature it doesn't work like it is in Eclipse, i.e. it uses different number of spaces in my xml files. Is there a way to configure it?
Yes, you can change it in the XML code style settings: