Wiki source code of Scala

Last modified by Sebastian Marsching on 2022/05/27 22:46

Show last authors
1 {{toc/}}
2
3 # Scala, Maven and Eclipse
4
5 An example `pom.xml` for using Maven for Scala with the Scala IDE for Eclipse can be found at [http://lampsvn.epfl.ch/trac/scala/wiki/ScalaEclipseMaven](http://lampsvn.epfl.ch/trac/scala/wiki/ScalaEclipseMaven).
6
7 For weave4j a slightly modified `pom.xml` is used:
8
9 ```xml
10
11 <project xmlns="http://maven.apache.org/POM/4.0.0"
12 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
14
15 <artifactId>weave4j</artifactId>
16 <groupId>org.marsching.weave4j</groupId>
17 <version>1.0.0</version>
18
19 <modelVersion>4.0.0</modelVersion>
20
21 <packaging>war</packaging>
22
23 <properties>
24 <scala.version>2.7.7</scala.version>
25 <spring.version>3.0.0.RELEASE</spring.version>
26 </properties>
27
28 <dependencies>
29
30 <!-- Because this is a web app, we also have a dependency on the servlet api. -->
31 <dependency>
32 <groupId>javax.servlet</groupId>
33 <artifactId>servlet-api</artifactId>
34 <version>2.5</version>
35 <scope>provided</scope>
36 </dependency>
37
38 <!-- Data source connection pool -->
39 <dependency>
40 <groupId>commons-dbcp</groupId>
41 <artifactId>commons-dbcp</artifactId>
42 <version>1.2.2</version>
43 </dependency>
44
45 <!-- Database driver -->
46 <dependency>
47 <groupId>org.hsqldb</groupId>
48 <artifactId>hsqldb</artifactId>
49 <version>1.8.0.10</version>
50 </dependency>
51
52 <!-- Hibernate -->
53 <dependency>
54 <groupId>org.hibernate</groupId>
55 <artifactId>hibernate-core</artifactId>
56 <version>3.3.2.GA</version>
57 </dependency>
58
59 <!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
60 <dependency>
61 <groupId>org.slf4j</groupId>
62 <artifactId>slf4j-simple</artifactId>
63 <version>1.5.8</version>
64 </dependency>
65
66 <!-- Byte code instrumentation for Hibernate -->
67 <dependency>
68 <groupId>javassist</groupId>
69 <artifactId>javassist</artifactId>
70 <version>3.8.0.GA</version>
71 </dependency>
72
73 <!-- Spring libraries -->
74 <dependency>
75 <groupId>org.springframework</groupId>
76 <artifactId>spring-webmvc</artifactId>
77 <version>${spring.version}</version>
78 </dependency>
79
80 <dependency>
81 <groupId>org.springframework</groupId>
82 <artifactId>spring-tx</artifactId>
83 <version>${spring.version}</version>
84 </dependency>
85
86 <dependency>
87 <groupId>org.springframework</groupId>
88 <artifactId>spring-orm</artifactId>
89 <version>${spring.version}</version>
90 </dependency>
91
92 <!-- Jackson JSON Mapper -->
93 <dependency>
94 <groupId>org.codehaus.jackson</groupId>
95 <artifactId>jackson-mapper-asl</artifactId>
96 <version>1.4.1</version>
97 </dependency>
98
99 <!-- Used for Base64 decoding -->
100 <dependency>
101 <groupId>commons-codec</groupId>
102 <artifactId>commons-codec</artifactId>
103 <version>1.4</version>
104 </dependency>
105
106 <!-- Scala dependencies -->
107 <dependency>
108 <groupId>org.scala-lang</groupId>
109 <artifactId>scala-library</artifactId>
110 <version>${scala.version}</version>
111 </dependency>
112
113 <dependency>
114 <groupId>org.scala-lang</groupId>
115 <artifactId>scala-compiler</artifactId>
116 <version>${scala.version}</version>
117 </dependency>
118
119 </dependencies>
120
121 <build>
122 <plugins>
123 <plugin>
124 <groupId>org.scala-tools</groupId>
125 <artifactId>maven-scala-plugin</artifactId>
126 <version>2.7.2</version>
127 <executions>
128 <execution>
129 <id>scala-compile-first</id>
130 <phase>process-resources</phase>
131 <goals>
132 <goal>add-source</goal>
133 <goal>compile</goal>
134 </goals>
135 </execution>
136 <execution>
137 <id>scala-test-compile</id>
138 <phase>process-test-resources</phase>
139 <goals>
140 <goal>testCompile</goal>
141 </goals>
142 </execution>
143 </executions>
144 <configuration>
145 <scalaVersion>${scala.version}</scalaVersion>
146 <args>
147 <arg>-target:jvm-1.5</arg>
148 </args>
149 </configuration>
150 </plugin>
151
152 <plugin>
153 <groupId>org.apache.maven.plugins</groupId>
154 <artifactId>maven-compiler-plugin</artifactId>
155 <configuration>
156 <source>1.5</source>
157 <target>1.5</target>
158 </configuration>
159 <executions>
160 <execution>
161 <phase>compile</phase>
162 <goals>
163 <goal>compile</goal>
164 </goals>
165 </execution>
166 </executions>
167 </plugin>
168
169 <plugin>
170 <groupId>org.codehaus.mojo</groupId>
171 <artifactId>build-helper-maven-plugin</artifactId>
172 <version>1.4</version>
173 <executions>
174 <execution>
175 <id>add-source</id>
176 <phase>generate-sources</phase>
177 <goals>
178 <goal>add-source</goal>
179 </goals>
180 <configuration>
181 <sources>
182 <source>src/main/scala</source>
183 <source>src/main/java</source>
184 </sources>
185 </configuration>
186 </execution>
187 <execution>
188 <id>add-test-source</id>
189 <phase>generate-sources</phase>
190 <goals>
191 <goal>add-test-source</goal>
192 </goals>
193 <configuration>
194 <sources>
195 <source>src/test/scala</source>
196 <source>src/test/java</source>
197 </sources>
198 </configuration>
199 </execution>
200 </executions>
201 </plugin>
202
203 <plugin>
204 <artifactId>maven-eclipse-plugin</artifactId>
205 <configuration>
206 <sourceIncludes>
207 <sourceInclude>**/*.scala</sourceInclude>
208 </sourceIncludes>
209 <buildcommands>
210 <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
211 </buildcommands>
212 <additionalProjectnatures>
213 <!--
214 maven-eclipse-plugin puts this nature after
215 org.eclipse.jdt.core.javanature in .project so the project
216 will have a J badge instead of an S in the Package Explorer
217 -->
218 <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
219 </additionalProjectnatures>
220 <classpathContainers>
221 <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
222 <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
223 </classpathContainers>
224 </configuration>
225 </plugin>
226
227 </plugins>
228 </build>
229
230 <reporting>
231 <plugins>
232 <plugin>
233 <groupId>org.scala-tools</groupId>
234 <artifactId>maven-scala-plugin</artifactId>
235 <version>2.7.2</version>
236 <configuration>
237 <scalaVersion>${scala.version}</scalaVersion>
238 </configuration>
239 </plugin>
240 </plugins>
241 </reporting>
242
243
244 </project>
245 ```