IntelliJ IDEA Quick Start Project NotesRussell Bateman |
Let's create a project from scratch in IntelliJ IDEA. There are a few IDE skills and Java-practices to convey.
Note that I'm going to assume the following path for convenience here: /home/james/dev/hapi-v2. Click Finish.
▼ hapi-v2
▶ .idea
src
hapi-v2.iml
▶ External libraries
russ@nargothrond ~ $ cd ~/dev russ@nargothrond ~/dev/hapi-v2 $ mkdir -p src/main/java/ca/uhn/hl7v2/examples russ@nargothrond ~/dev/hapi-v2 $ mkdir -p src/test/java/ca/uhn/hl7v2/examples
russ@nargothrond ~/dev/hapi-v2/src $ sudo apt-get install tree russ@nargothrond ~/dev/hapi-v2/src $ tree . ├── main │ └── java │ └── ca │ └── uhn │ └── hl7v2 │ └── examples └── test └── java └── ca └── uhn └── hl7v2 └── examples
This is important because the canonical filesystem representation of Java source code is always the following.
russ@nargothrond ~/dev/hapi-v2/src $ tree -L 2 . ├── main │ ├── java production code │ └── resources production resources files like log4j.properties and other data used at runtime └── test ├── java test code └── resources test resources any file data consumed by JUnit tests
Note that, below this point, Java packages make up subdirectories in a hierarchy.
Here's a basic pom.xml. It goes at the root of the project.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ca.uhn.hl7v2.examples</groupId>
<artifactId>hl7-v2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>hl7-v2</name>
<description>Fun with HL7 v2</description>
<properties>
<junit.version>4.12</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
<!-- vim: set tabstop=2 shiftwidth=2 expandtab: -->
When we've finished, pom.xml will look like this.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-v2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>hapi-v2</name>
<description>Fun with HAPI</description>
<properties>
<hapi_v2.version>2.3</hapi_v2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-base</artifactId>
<version>${hapi_v2.version}</version>
</dependency>
<dependency>
<!-- ExampleParseMessages -->
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v22</artifactId>
<version>${hapi_v2.version}</version>
</dependency>
</dependencies>
</project>
<!-- vim: set tabstop=2 shiftwidth=2 expandtab: -->