Skip to content

Commit e7876d5

Browse files
committed
Merge pull request scala#2741 from retronym/topic/intellij-modular
Scrubbing up the IntelliJ Config
2 parents 4c62f7d + 02df8f3 commit e7876d5

16 files changed

+153
-23
lines changed

build.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ TODO:
128128

129129
<!-- Sets location of build folders -->
130130
<property name="build.dir" value="${basedir}/build"/>
131+
<property name="build-deps.dir" value="${build.dir}/deps"/>
131132
<property name="build-libs.dir" value="${build.dir}/libs"/>
132133
<property name="build-asm.dir" value="${build.dir}/asm"/>
133134
<property name="build-forkjoin.dir" value="${build-libs.dir}"/>
@@ -192,6 +193,18 @@ TODO:
192193
</touch>
193194
</target>
194195

196+
<macrodef name="copy-deps" description="Copy a file set based on maven dependency resolution to a directory. Currently used by the IntelliJ config files.">
197+
<attribute name="fileset.prefix"></attribute>
198+
<attribute name="out"></attribute>
199+
<sequential>
200+
<delete dir="${build-deps.dir}/@{out}" includes="*.jar"/>
201+
<copy todir="${build-deps.dir}/@{out}">
202+
<fileset refid="@{fileset.prefix}.fileset" />
203+
<mapper type="flatten" />
204+
</copy>
205+
</sequential>
206+
</macrodef>
207+
195208
<target name="init" depends="boot">
196209
<!-- Set up Ant contrib tasks so we can use <if><then><else> instead of the clunky `unless` attribute -->
197210
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${lib-ant.dir}/ant-contrib.jar"/>
@@ -218,6 +231,7 @@ TODO:
218231
<artifact:dependencies pathId="junit.classpath" filesetId="junit.fileset">
219232
<dependency groupId="junit" artifactId="junit" version="${junit.version}"/>
220233
</artifact:dependencies>
234+
<copy-deps fileset.prefix="junit" out="junit"/>
221235

222236
<!-- Pax runner -->
223237
<property name="pax.exam.version" value="2.5.0"/>
@@ -238,10 +252,12 @@ TODO:
238252
<dependency groupId="com.googlecode.java-diff-utils" artifactId="diffutils" version="1.3.0"/>
239253
<dependency groupId="org.scala-tools.testing" artifactId="test-interface" version="0.5" />
240254
</artifact:dependencies>
255+
<copy-deps fileset.prefix="partest.extras" out="partest"/>
241256

242257
<artifact:dependencies pathId="repl.deps.classpath" filesetId="repl.deps.fileset" versionsId="repl.deps.versions">
243258
<dependency groupId="jline" artifactId="jline" version="${jline.version}"/>
244259
</artifact:dependencies>
260+
<copy-deps fileset.prefix="repl.deps" out="repl"/>
245261

246262
<!-- BND support -->
247263
<typedef resource="aQute/bnd/ant/taskdef.properties" classpathref="extra.tasks.classpath" />

src/intellij/README

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
Use the latest IntelliJ IDEA release and install the Scala plugin from within the IDE.
22

33
The following steps are required to use IntelliJ IDEA on Scala trunk
4-
- compile "locker" using "ant locker.done"
5-
- Copy the *.iml.SAMPLE / *.ipr.SAMPLE files to *.iml / *.ipr
6-
- In IDEA, create a global library named "ant" which contains "ant.jar"
7-
- Also create an SDK entry named "1.6" containing the java 1.6 SDK
8-
- In the Scala Facet of the "library" and "reflect" modules, update the path in the
9-
command-line argument for "-sourcepath"
10-
- In the Project Settings, update the "Version Control" to match your checkout
11-
12-
Known problems
13-
- Due to SI-4365, the "library" module has to be built using "-Yno-generic-signatures"
4+
- compile "locker" using "ant locker.done". This will also download some JARs from
5+
Maven to ./build/deps, which are included in IntelliJ's classpath.
6+
- Run src/intellij/setup.sh
7+
- Open ./src/intellij/scala-lang.ipr in IntelliJ
8+
- File, Project Settings, Project, SDK. Create an SDK entry named "1.6" containing the java 1.6 SDK

src/intellij/compiler.iml.SAMPLE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
<orderEntry type="sourceFolder" forTests="false" />
2020
<orderEntry type="module" module-name="library" />
2121
<orderEntry type="module" module-name="reflect" />
22-
<orderEntry type="module" module-name="asm" />
23-
<orderEntry type="library" name="ant" level="application" />
24-
<orderEntry type="library" name="jline" level="project" />
22+
<orderEntry type="module" module-name="asm" exported="" />
23+
<orderEntry type="library" exported="" name="ant" level="project" />
2524
</component>
2625
</module>
2726

src/intellij/diff.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Diffs the SAMPLE files against the working project config.
4+
#
5+
export SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
6+
for f in "$SCRIPT_DIR"/*.{iml,ipr}; do
7+
echo $f; diff -u $f.SAMPLE $f;
8+
done

src/intellij/library.iml.SAMPLE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<configuration>
66
<option name="compilerLibraryLevel" value="Project" />
77
<option name="compilerLibraryName" value="compiler-locker" />
8-
<option name="compilerOptions" value="-sourcepath /Users/luc/scala/scala/src/library -Yno-generic-signatures" />
8+
<option name="compilerOptions" value="-sourcepath $BASE_DIR$/src/library" />
99
<option name="maximumHeapSize" value="1536" />
1010
<option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
1111
</configuration>

src/intellij/manual.iml.SAMPLE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
<orderEntry type="inheritedJdk" />
1919
<orderEntry type="sourceFolder" forTests="false" />
2020
<orderEntry type="module" module-name="library" />
21-
<orderEntry type="library" name="ant" level="application" />
21+
<orderEntry type="module" module-name="xml" />
22+
<orderEntry type="library" name="ant" level="project" />
2223
</component>
2324
</module>
2425

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="scala" name="Scala">
5+
<configuration>
6+
<option name="compilerLibraryLevel" value="Project" />
7+
<option name="compilerLibraryName" value="compiler-locker" />
8+
<option name="maximumHeapSize" value="1536" />
9+
<option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
10+
</configuration>
11+
</facet>
12+
</component>
13+
<component name="NewModuleRootManager" inherit-compiler-output="true">
14+
<exclude-output />
15+
<content url="file://$MODULE_DIR$/../parser-combinators">
16+
<sourceFolder url="file://$MODULE_DIR$/../parser-combinators" isTestSource="false" />
17+
</content>
18+
<orderEntry type="inheritedJdk" />
19+
<orderEntry type="sourceFolder" forTests="false" />
20+
<orderEntry type="module" module-name="library" />
21+
</component>
22+
</module>

src/intellij/partest.iml.SAMPLE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
<orderEntry type="inheritedJdk" />
1919
<orderEntry type="sourceFolder" forTests="false" />
2020
<orderEntry type="module" module-name="library" />
21+
<orderEntry type="module" module-name="xml" />
2122
<orderEntry type="module" module-name="reflect" />
2223
<orderEntry type="module" module-name="actors" />
2324
<orderEntry type="module" module-name="scalap" />
2425
<orderEntry type="module" module-name="compiler" />
25-
<orderEntry type="library" name="ant" level="application" />
26+
<orderEntry type="library" name="partest-deps" level="project" />
27+
<orderEntry type="module" module-name="repl" />
2628
</component>
2729
</module>
2830

src/intellij/reflect.iml.SAMPLE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<configuration>
66
<option name="compilerLibraryLevel" value="Project" />
77
<option name="compilerLibraryName" value="compiler-locker" />
8-
<option name="compilerOptions" value="-sourcepath /Users/luc/scala/scala/src/reflect" />
8+
<option name="compilerOptions" value="-sourcepath $BASE_DIR$/src/reflect" />
99
<option name="maximumHeapSize" value="1536" />
1010
<option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
1111
</configuration>

src/intellij/repl.iml.SAMPLE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
<orderEntry type="module" module-name="library" />
2121
<orderEntry type="module" module-name="reflect" />
2222
<orderEntry type="module" module-name="compiler" />
23+
<orderEntry type="library" name="repl-deps" level="project" />
2324
</component>
2425
</module>
25-

src/intellij/scala-lang.ipr.SAMPLE

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<component name="EntryPointsManager">
3434
<entry_points version="2.0" />
3535
</component>
36+
<component name="HighlightingAdvisor">
37+
<option name="SUGGEST_TYPE_AWARE_HIGHLIGHTING" value="false" />
38+
</component>
3639
<component name="InspectionProjectProfileManager">
3740
<profiles>
3841
<profile version="1.0" is_locked="false">
@@ -204,6 +207,7 @@
204207
<module fileurl="file://$PROJECT_DIR$/interactive.iml" filepath="$PROJECT_DIR$/interactive.iml" />
205208
<module fileurl="file://$PROJECT_DIR$/library.iml" filepath="$PROJECT_DIR$/library.iml" />
206209
<module fileurl="file://$PROJECT_DIR$/manual.iml" filepath="$PROJECT_DIR$/manual.iml" />
210+
<module fileurl="file://$PROJECT_DIR$/parser-combinators.iml" filepath="$PROJECT_DIR$/parser-combinators.iml" />
207211
<module fileurl="file://$PROJECT_DIR$/partest.iml" filepath="$PROJECT_DIR$/partest.iml" />
208212
<module fileurl="file://$PROJECT_DIR$/reflect.iml" filepath="$PROJECT_DIR$/reflect.iml" />
209213
<module fileurl="file://$PROJECT_DIR$/repl.iml" filepath="$PROJECT_DIR$/repl.iml" />
@@ -212,6 +216,7 @@
212216
<module fileurl="file://$PROJECT_DIR$/scalap.iml" filepath="$PROJECT_DIR$/scalap.iml" />
213217
<module fileurl="file://$PROJECT_DIR$/swing.iml" filepath="$PROJECT_DIR$/swing.iml" />
214218
<module fileurl="file://$PROJECT_DIR$/test.iml" filepath="$PROJECT_DIR$/test.iml" />
219+
<module fileurl="file://$PROJECT_DIR$/xml.iml" filepath="$PROJECT_DIR$/xml.iml" />
215220
</modules>
216221
</component>
217222
<component name="ProjectResources">
@@ -228,6 +233,13 @@
228233
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
229234
</component>
230235
<component name="libraryTable">
236+
<library name="ant">
237+
<CLASSES>
238+
<root url="jar://$PROJECT_DIR$/../../lib/ant/ant.jar!/" />
239+
</CLASSES>
240+
<JAVADOC />
241+
<SOURCES />
242+
</library>
231243
<library name="compiler-locker">
232244
<CLASSES>
233245
<root url="file://$PROJECT_DIR$/../../build/locker/classes/library" />
@@ -238,13 +250,35 @@
238250
<JAVADOC />
239251
<SOURCES />
240252
</library>
241-
<library name="jline">
253+
<library name="junit">
242254
<CLASSES>
243-
<root url="jar://$PROJECT_DIR$/../../lib/jline.jar!/" />
255+
<root url="file://$PROJECT_DIR$/../../build/deps/junit" />
244256
</CLASSES>
245257
<JAVADOC />
246-
<SOURCES />
258+
<SOURCES>
259+
<root url="file://$PROJECT_DIR$/../../build/deps/junit" />
260+
</SOURCES>
261+
<jarDirectory url="file://$PROJECT_DIR$/../../build/deps/junit" recursive="false" />
262+
<jarDirectory url="file://$PROJECT_DIR$/../../build/deps/junit" recursive="false" type="SOURCES" />
263+
</library>
264+
<library name="partest-deps">
265+
<CLASSES>
266+
<root url="file://$PROJECT_DIR$/../../build/deps/partest" />
267+
</CLASSES>
268+
<JAVADOC />
269+
<SOURCES>
270+
<root url="file://$PROJECT_DIR$/../../build/deps/junit" />
271+
</SOURCES>
272+
<jarDirectory url="file://$PROJECT_DIR$/../../build/deps/partest" recursive="false" />
273+
<jarDirectory url="file://$PROJECT_DIR$/../../build/deps/junit" recursive="false" type="SOURCES" />
247274
</library>
275+
<library name="repl-deps">
276+
<CLASSES>
277+
<root url="file://$PROJECT_DIR$/../../build/deps/repl" />
278+
</CLASSES>
279+
<JAVADOC />
280+
<SOURCES />
281+
<jarDirectory url="file://$PROJECT_DIR$/../../build/deps/repl" recursive="false" />
282+
</library>
248283
</component>
249284
</project>
250-

src/intellij/scala.iml.SAMPLE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<module type="JAVA_MODULE" version="4">
33
<component name="NewModuleRootManager" inherit-compiler-output="true">
44
<exclude-output />
5-
<content url="file://$MODULE_DIR$/../.." />
5+
<content url="file://$MODULE_DIR$/../..">
6+
<excludeFolder url="file://$MODULE_DIR$/../../build" />
7+
</content>
68
<orderEntry type="inheritedJdk" />
79
<orderEntry type="sourceFolder" forTests="false" />
810
</component>

src/intellij/scaladoc.iml.SAMPLE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020
<orderEntry type="module" module-name="library" />
2121
<orderEntry type="module" module-name="reflect" />
2222
<orderEntry type="module" module-name="compiler" />
23+
<orderEntry type="module" module-name="xml" />
24+
<orderEntry type="module" module-name="parser-combinators" />
25+
<orderEntry type="module" module-name="partest" />
2326
</component>
2427
</module>

src/intellij/setup.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Generates IntelliJ IDEA project files based on the checked-in samples.
4+
#
5+
6+
set -e
7+
export SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
8+
export BASE="$( cd "$( dirname "$0" )"/../.. && pwd )"
9+
echo "About to delete .ipr and .iml files and replace with the .SAMPLE files. Press enter to continue or CTRL-C to cancel."
10+
read
11+
12+
(rm *.ipr *.iml 2>/dev/null)
13+
for f in $(ls "$SCRIPT_DIR"/*.SAMPLE); do
14+
NEW_FILE=`echo $f | perl -pe 's/.SAMPLE//'`;
15+
16+
cp $f $NEW_FILE
17+
18+
# IntelliJ doesn't process the "compilerOptions" setting for variable
19+
# replacement. If it did, we would just use "$PROJECT_DIR$". Instead,
20+
# we do this replacement ourselves.
21+
perl -pi -e 's/\$BASE_DIR\$/$ENV{"BASE"}/g' $NEW_FILE
22+
echo "Created $NEW_FILE"
23+
done

src/intellij/test.iml.SAMPLE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
<orderEntry type="inheritedJdk" />
77
<orderEntry type="sourceFolder" forTests="false" />
88
<orderEntry type="module" module-name="library" />
9+
<orderEntry type="module" module-name="xml" />
10+
<orderEntry type="module" module-name="parser-combinators" />
911
<orderEntry type="module" module-name="reflect" />
1012
<orderEntry type="module" module-name="compiler" />
1113
<orderEntry type="module" module-name="actors" />
1214
<orderEntry type="module" module-name="swing" />
1315
<orderEntry type="module" module-name="partest" />
1416
<orderEntry type="module" module-name="asm" />
1517
<orderEntry type="module" module-name="forkjoin" />
18+
<orderEntry type="library" name="junit" level="project" />
1619
</component>
1720
</module>
1821

src/intellij/xml.iml.SAMPLE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="scala" name="Scala">
5+
<configuration>
6+
<option name="compilerLibraryLevel" value="Project" />
7+
<option name="compilerLibraryName" value="compiler-locker" />
8+
<option name="maximumHeapSize" value="1536" />
9+
<option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
10+
</configuration>
11+
</facet>
12+
</component>
13+
<component name="NewModuleRootManager" inherit-compiler-output="true">
14+
<exclude-output />
15+
<content url="file://$MODULE_DIR$/../xml">
16+
<sourceFolder url="file://$MODULE_DIR$/../xml" isTestSource="false" />
17+
</content>
18+
<orderEntry type="inheritedJdk" />
19+
<orderEntry type="sourceFolder" forTests="false" />
20+
<orderEntry type="module" module-name="library" />
21+
</component>
22+
</module>

0 commit comments

Comments
 (0)