Workaround IntelliJ mishandling of system-scoped dependencies
IntelliJ loads system dependencies in compile scope, which tools.jar
to be added to the classpath and causes problems when running with Java 9
<scope>test</scope>
</dependency>
</dependencies>
+
+ <profiles>
+ <profile>
+ <!-- TODO: remove after upgrade to Java 9 -->
+ <!-- IntelliJ incorrectly loads "system" dependencies in "compile" scope. This is problematic
+ for running programs from IntelliJ using Java 9, because it places tools.jar in the classpath.
+ This hack allows us to only include tools.jar during compilation from the command line. -->
+ <id>lib/tools.jar</id>
+ <activation>
+ <property>
+ <name>!idea.maven.embedder.version</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.8</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
</project>
