-
Notifications
You must be signed in to change notification settings - Fork 180
IntelliJ IDEA specific development instructions
-
download IntelliJ IDEA Community from the official site, tarball with bundled JDK for Linux
-
mseidl recommends using the jb toolbox(https://www.jetbrains.com/toolbox/) if you use this to install it, it makes upgrading easier. intellij cannot upgrade it self, nor can you upgrade by untarring the new version. But the toolbox makes upgrades easy.
-
create the file
~/.IntelliJIdea*/config/idea64.vmoptions
with-Xmx4G
-
run
bin/idea.sh
and go through the installation wizard -
click on Import Project, select the
spacewalk
directory -
select Create project from existing sources
-
accept project format defaults and auto-discovered source directories by clicking Next
-
from the Libaries list, uncheck all items
-
from the Modules list, only check the items corresponding to the following directories:
-
spacewalk/java/code
(change the name tocode
) -
spacewalk/branding/java/code
(change the name tobranding
)
-
-
add an appropriate JDK location (1.8 for 3.0 and 3.1) and click on Finish. On openSUSE the JDK path is
/etc/alternatives/java_sdk_11/
IntelliJ will complain about corrupted SDK, but this error can be ignored. -
enable automatic building:
- click on File -> Settings... -> Build, Execution, Deployment -> Compiler and flag Build project automatically
-
configure import organization rules consistent with the project:
- click on File -> Settings... -> Editor -> Code Style -> Java -> Imports
Either click on the cog icon > Import Scheme > IntelliJ IDEA code style XML and select the <repo_root>/java/conf/intellij-codestyle.xml
file, or do the following changes:
- check *Use single class import*
- check *Layout static imports separately*
- edit the *Import Layout* list to contain:
- *import static all other imports*
- *`<blank line>`*
- *import com.redhat.rhn.**
- *`<blank line>`*
- *import com.suse.**
- *`<blank line>`*
- *import com.**
- *`<blank line>`*
- *import org.**
- *`<blank line>`*
- *import java.**
- *`<blank line>`*
- *import javax.**
- *`<blank line>`*
- *import all other imports*
- click on File -> Project Structure... -> Modules ->
code
-> Dependencies -> + -> Module dependency -> branding -> OK to include branding classes and files in the build - click on File -> Project Structure... -> Modules ->
code
and mark the directorywebapp
as Resources - click on Run -> Edit Configurations... -> Defaults -> JUnit and edit the form on the right hand side panel
- if you need to limit the tests to be run to a package, add the package name in Package:
- select In single module
- add the following VM options:
-ea -Drhn.config.dir=$MODULE_DIR$/../buildconf/test/ -Dlog4j.threshold=debug
- click OK
- click on Run -> Run:
- to debug a remote instance:
- click on Run -> Edit Configurations... -> + sign. Accept all defaults apart from Host and Port:
- 8003 for Tomcat, 8001 for Taskomatic, 8002 for Search by default on sumaform
- click on Run -> Edit Configurations... -> + sign. Accept all defaults apart from Host and Port:
- click on File -> Settings... -> Plugins -> Browse repositories... -> type "IvyIDEA" -> Install to install the Ivy plugin
- click on Restart IntelliJ IDEA to activate the plugin
- click on File -> Project Structure... -> Modules -> right click on
code
-> + -> ivyIDEA to enable the plugin for the project - click on ... (top) to select the Ivy configuration path:
spacewalk/java/buildconf/ivy/ivy-suse.xml
- flag Use module specific ivy settings
- click on ... (bottom) to select the Ivy configuration path:
spacewalk/java/buildconf/ivy/ivyconf.xml
- click on Tools -> IvyIDEA -> Resolve for all modules to get updated Ivy dependencies
When switching branches that have different dependencies (notably, major versions) you will have to click on:
- Tools -> IvyIDEA -> Remove all resolved libraries
- Tools -> IvyIDEA -> Resolve for all modules
- Build -> Rebuild project
- click on File -> Settings... -> Plugins -> Browse repositories... -> type "CheckStyle-IDEA" -> Install to install the CheckStyle plugin
- click on Restart IntelliJ IDEA to activate the plugin
- click on File -> Settings... -> Other Settings -> Checkstyle and change Checkstyle version to the version in
buildconf/ivy/ivy-suse.xml
(currently 10.12.7), click on Apply - click on the + sign next to Configuration File
- Description: SUSE Manager
- select Use a local Checkstyle file, select
spacewalk/java/buildconf/checkstyle.xml
- flag Store relative to project location, click on Next
- set the following values for properties:
-
checkstyle.cache.file
:<PATH_TO>/spacewalk/java/build/checkstyle.cache.src
-
checkstyle.header.file
:<PATH_TO>/spacewalk/java/buildconf/LICENSE.txt
-
checkstyle.suppressions.file
:<PATH_TO>/spacewalk/java/buildconf/checkstyle-suppressions.xml
-
javadoc.lazy
:false
-
javadoc.method.scope
:public
-
javadoc.type.scope
:package
-
javadoc.var.scope
:package
-
- click on Finish, then flag the file as Active, then click on Apply one more time
- one new mini-tab will appear at the bottom of the screen with options
These are recommended IDE settings that help respecting style guidelines independent of the CheckStyle plugin:
- enabling automatic import completion: click on File -> Settings... -> Editor -> General -> Auto Import -> Insert imports on paste: -> select All. On the same form, check Add unambiguous imports on the fly and Optimize imports on the fly (for current project)
- disabling "star imports": click on File -> Settings... -> Editor -> Code Style -> Java -> Imports -> Class count to use import with '*' -> 999 and Names count to use static import with '*' -> 999
- wrapping and braces: Settings... -> Editor -> Code Style -> Java -> Wrapping and Braces. Under 'try' statement check 'catch' on new line and 'finally' on new line; under 'if' statement check 'else' on new line
- change the output directory to enable quick
manager-build.xml
deploys:- click on File -> Project Structure... -> Modules ->
code
-> Paths, click on Use module compile output path and set: -
Output path to
spacewalk/java/build/classes
-
Test output path to
spacewalk/java/build/tests
- click on File -> Project Structure... -> Modules ->
- grab Ivy dependencies in the
spacewalk/lib
directory:ant -f manager-build.xml ivy
- enable precompiled file use by adding a
precompiled=true
line inbuildconf/manager-developer-build.properties
(e.g. make a copy ofbuildconf/manager-developer-build.properties.example
, then rename and edit the new file).
All imports red? Try any the following:
File -> Synchronize
File -> Invalidate caches / Restart