Intellij -Project structure settings (spring facet config) - where are they stored? - java

Have a project that I am migrating over from netbeans to intellij.
Intellij recognises the spring config files and gives the warning "please configure/setup spring facet for modules". This requires manually adding these under project structure settings.
I don't want the other team members to all have to do this manually, so I wish to check these settings into git, but according to that, there are no changed files in the project directory (I have standard ignores added to .gitignore). I have also tried searches of file contents for the config file names etc and that turns up nothing too.
So my question is where are the settings stored? In a file that is typically on the ignored list or in a location external to the project directory?

Essentially all the IDEA related configuration for the project is under .idea folder, for example, all the project workspace iteams you can find in the .idea/worksapce.xml, include the spring features you mentioned.
But this is not a good idea to keep those things in your VCs, the .idea folder is ignore default as in the configuration items will store you local env related like the full path to your local gradle, e.g.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:/DevTools/gradle-2.14.1" />
<option name="gradleJvm" value="#JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="useAutoImport" value="true" />
<option name="myModules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
Here are some files under the .idea folder for my proejct
Update:
For the spring facets, it's under the module .iml file, like
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration>
<fileset id="fileset" name="Spring Application Context" removed="false">
<file>file://$MODULE_DIR$/src/main/resources/META-INF/spring/integration-beans.xml</file>
</fileset>
</configuration>
</facet>
</component>

Related

How to validate invalid Cucumber/Gherkin .feature file in build?

If I create step in Cucumber .feature file that is not implemented I get snippet in logs.
But if I make error in .feature file like starting new line with "Andd" or with anything but keywords (given, when..) then I get error in IntelliJ "Unexpected element" which is underlined and that's great.
But despite that when I build project I get "success build".
Also when I go further and run Cucumber tests I get
"0 Scenarios, 0 Steps found." and no explanation why.
Is there any build parameter that can be added to mark such build unsuccessful?
Is there any way to point to such errors?
Edit: when running from cmd 'mvn test..' I get nice stack trace.
Problem is only when running in Intellij > Run/Debug Configuration.
Sample .run.xml that I am using:
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Feature: testFeed" type="CucumberJavaRunConfigurationType" factoryName="Cucumber java" nameIsGenerated="true">
<option name="CUCUMBER_CORE_VERSION" value="5" />
<option name="FILE_PATH" value="$PROJECT_DIR$/src/test/resources/features/testFeed.feature" />
<option name="GLUE" value="com.testing.stepdefiniton" />
<option name="MAIN_CLASS_NAME" value="io.cucumber.core.cli.Main" />
<module name="testing" />
<option name="PROGRAM_PARAMETERS" value=" --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter" />
<shortenClasspath name="NONE" />
<option name="SUGGESTED_NAME" value="Feature: testFeed" />
<option name="VM_PARAMETERS" value="-Dspring.profiles.active=local -Dcucumber.filter.tags="#test"" />
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="io.cucumber.core.cli.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
There are two parts to this question
You usage of IntelliJ (I can't help you with this)
Your usage of Cucumber (maybe I can help here)
Cucumber is telling you that it can't find any scenarios or any steps. Its not going to contribute until you can fix that. You need to either try running Cucumber from the command line, or configure IntelliJ correctly so it can find the features and steps when running cucumber.

How to make VS Code organize Java imports like IntelliJ

I'm using VS Code for Java development and working with other developers who use IntelliJ. I'd like to use the Organize Imports command (Shift+Alt+O) to clean up my imports, but I don't want to fight over import order with every commit. So I'd like to configure VS Code to organize the imports in the same order as IntelliJ's default. Does anybody have a configuration that would do this?
If this is not possible, is there a workspace configuration I can apply to both VS Code and IntelliJ so that the two IDEs will agree, even if they aren't agreeing on IntelliJ's default?
We were able to get it the almost identical with the following config tweaks.
VS Code:
{
"java.completion.importOrder": [
"",
"javax",
"java",
"#"
]
}
IntelliJ
The only difference from the IntelliJ default is a new line between import javax... and import java....
It's possible to get VS Code and IntelliJ to agree on a standard format, as long as that standard format:
Puts static imports at the top*
Separates all specific sections with empty lines
Puts everything not in its own specific section in a catch-all section at the end*
Never uses wildcard imports
Not actually true; static imports can be positioned in VS Code with '#', and everything else can be position in VS Code with ''.
IntelliJ's default settings don't work for this, but it is flexible enough to be reconfigured. Here are the files to add to a project to make just that project set up consistent rules for both IDEs (make sure they are not excluded in .gitignore).
Rule: The following groups separated by empty lines: Static imports, java.*, javax.*, everything else.
.vscode/settings.json:
{
"java.completion.importOrder": ["java", "javax"],
}
.idea/codeStyles/codeStyleConfig.xml:
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
.idea/codeStyles/Project.xml
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
</value>
</option>
</JavaCodeStyleSettings>
</code_scheme>
</component>

How to properly import Java code style settings with IntelliJ?

I tried to import Google's Java code style with IntelliJ.
The style file contains the following configuration:
<code_scheme name="GoogleStyle">
<option name="JAVA_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
...
</value>
</option>
...
</code_scheme>
But after the import my settings still show
Tab size 4 (instead of 8)
Indent 4 (instead of 2)
Continuation indent 8 (instead of 4)
When I export that style scheme then in the output file the values are the same as in the original file:
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
Steps I took to import the style:
Navigate to Settings -> Editor -> Code Style -> Java
Click Manage button next to Scheme dropdown -> Import... -> IntelliJ IDEA code style XML
From the Scheme dropdown select the new option (called "GoogleStyle")
Apply
I'm using IntelliJ IDEA Community 2016.2.2
The expected result is that when I import the style then created style scheme has indent size (etc) the same as specified in the code scheme file.
How can I do that?
EDITED
The file from Google uses an old (I suppose) key for filetype (java instead of Java). I have made the following changes and it works.
<ADDITIONAL_INDENT_OPTIONS fileType="JAVA">
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
<option name="USE_TAB_CHARACTER" value="false" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</ADDITIONAL_INDENT_OPTIONS>
I have made a fork of the GitHub repository with the file corrected (https://github.com/nhenneaux/styleguide/blob/gh-pages/intellij-java-google-style.xml).
The easiest way is to import the style file into ~/.IntelliJIdea2016.2/config/codestyles. Then you have to restart Intellij and go in the style settings to select GoogleStyle.
It seems that the format used in the configuration file differes from what IntelliJ (at least the version I'm using) expects.
I changed my code setting, exported them and looked for differences.
The ident setting were in the output file like so:
<code_scheme name="MyTestStyle">
...
<codeStyleSettings language="JAVA">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
Importing this file worked as expected.

How to have Android Studio generate R.java?

Today I've been struggling to get my Android Application to work in Android Studio. I've imported the project from an Eclipse project. However, the wrong R.java file is created.
Everywhere in the code the R is red: Cannot resolve symbol "R". And when hovering the import statement (import com.example.myproject.R;): Unused import statement. I do not know where the R.java is created or should be located, but here's my guess: $MODULE$/build/generated/source/r/debug/com/example/myproject/R.java.
That is, because the $MODULE/build/generated/source/r/release/com/example/myproject/R.java is being generated, but not the /debug/ version. If I copy the /release/ R.java file to the /debug/com/example/myproject/ directory, all errors solve themselves. But how can I make Android Studio to always generated the /debug/ R.java file?
The myproject.iml file shows:
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
.... etc..
So why is the R.java in the release folder generated?
In my case, the
<facet type="java-gradle" name="Java-Gradle">
part is strangely missing in my .iml file
...
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":listpopupmenu" />
</configuration>
</facet>
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
<facet type="android" name="Android">
...
after adding that part, it works as expected.

Unable to load Java Runtime Environment with embedded jre

I am trying to bundle a java application on windows for mac using appbundler-1.0.jar and Ant with an embedded jre 7.
This is the build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="AppName" default="default" basedir=".">
<property environment="env" />
<taskdef
name="bundleapp"
classname="com.oracle.appbundler.AppBundlerTask"
classpath="lib/appbundler-1.0.jar" />
<target name="bundle-AppName">
<bundleapp
outputdirectory="dist"
name="AppName"
displayname="AppName"
identifier="com.hmf.AppName"
icon="files\logo48.icns"
shortversion="1.0"
mainclassname="hmf.AppName.app">
<classpath file="files/AppName.jar" />
<librarypath dir="pathToLibraries" />
<option value="-Dapple.laf.useScreenMenuBar=false"/>
<option value="-XstartOnFirstThread=true"/>
<option value="-Dcom.apple.macos.useScreenMenuBar=false"/>
<option value="-Dcom.apple.smallTabs=true"/>
<option value="-Dsun.java2d.d3d=false"/>
<option value="-Derby.storage.pageSize=8192"/>
<option value="-Djava.library.path=lib/swt.jar:lib"/>
<option value="-Xmx1400M"/>
</bundleapp>
</target>
</project>
I then copy jre 7 for mac to PlugIns directory under AppName.app. (I cant make it work with the runtiime tag)
But when I try to run the application I get:
"Unable to load Java Runtime Environment".
When OS use system jre it works but I want to be able to use the embedded jre.
Also see:
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
Application is using Java 6 from Apple instead of Java 7 from Oracle on Mac OS X?
I've solved the issue with my "Unable to load Java Runtime Environment" by using an installed JDK as the jre to be embedded within my app. I was until now using a jre unzipped within a user folder. with the JDK I set the environment variable at the command line
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
I then used the
<runtime dir="${env.JAVA_HOME}" />
and it worked as the jre gets installed under the Plugins directory as it should i.e no need to manually copy jre

Categories