maven and editing related questions about IDEA 12.

I am new to IntelliJ IDEA, and I am using 12.1.4.

  • Maven related

I tried to create a maven project, and then add two sub modules.
This is the project structure:

As you can see,the

mavenapp
is the root project(parent project), while the
app-common
and
app-web
are the sub modules.
IntelliJ IDEA does the right thing by modify the pom.xml of
mavenapp
:
<modules>
    <module>app-common</module>
    <module>app-web</module>
</modules>
<packaging>pom</packaging>

Now I have some problems:
1) make

app-common
as a dependency of
app-web
?


That's to say, I want to IntelliJ IDEA modify the pom.xml of

app-web
:
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>app-common</artifactId>
        <version>${project.version}</version>
    </dependency>

But I can not find how to make it? I can not find the

app-common
module at the
Maven Artifact Search
dialog box.

2) extract the repeated dependencies to the
dependencyManagement
of the pom.xml of the parent


While I mean if the
app-common
and
app-webapp
have some same dependencies, for example, the
junit
dependency.
It would be better if we define the
junt
in the
dependencyManagement
of the pom.xml of
mavenapp
, I wonder if the IDE can make it for us?

  • Edition related

I used to use the Eclipse before, so I found something I can not make it in IDEA.


1) When I type a "stri", then press key "alt+."(I have changed the key map of "Main menu-Code-Completion-Basic to alt+."), I got nothing. While in eclispe I will get this:


2) How to display all the counstructor of a class as this:


3) the format(I use the Ctrl+Shift+F).

For this kind of codes:

In eclipse it will format the line as one line to this:

IDEA does not. I have to delete the "\n" manually.


I have googled for all of the above questions, but I got no answer(maybe by my wrong search keys).


I hope someone can help me .

Thanks.

3 comments

Hello,

Will ask our maven guy to comment on maven questions.

Regarding editing support - completion is case-sensitive by default, i.e. you should type not 'stri' but 'Stri' in order to get 'String' at completion variants. However, you can make it case-insensitive at 'ide settings | editor | code completion | case sensitive completion'.

Displaying all appropriate constructors - there is no such functionality per se. I.e. you should choose a class name (constructor will be inserted to the code) and then list all overloaded methods. It's more convenient to complete class name using 'smart completion' instead of basic completion (main menu | code | completion | smart type). E.g. it will insert 'new String()' for your sample but offer various CharSequence implementations for code 'CharSequence s = new '. Then you should use 'parameter info' action to list all overloaded methods ('main menu | view | parameter info', mapped to Ctrl+P at the default keymap).

Formatting - please uncheck 'project settings | code style | java | wrapping and braces | keep when reformatting | line breaks' for getting desired result.

Denis

0

About maven related questions:
1.) Maven Artifact Search dialog finds dependencies in local repository and index of remote repository. May be it's a bug that Maven Artifact Search doesn't contain project modules. You have to add dependency manually.

2.) There is "Extract managed dependency" refactoring. Right click on <dependency> element, select Refactor -> Extract -> "Extract Managed dependency"

0

@denis:

Thanks, I will have a try.

0

Please sign in to leave a comment.