Skip to content
Browse files

add support of scala-maven-plugin

  • Loading branch information...
1 parent 3b1ec65 commit dc9b6467778c9f96c51f4c373035dad2ed415e36 @davidB davidB committed Apr 1, 2012
View
53 org.maven.ide.eclipse.scala/lifecycle-mapping-metadata.xml
@@ -2,7 +2,58 @@
<lifecycleMappingMetadata>
<pluginExecutions>
- <!-- scala maven plugins -->
+ <!-- scala-maven-plugin -->
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ <versionRange>[3.0,)</versionRange>
+ </pluginExecutionFilter>
+ <action>
+ <configurator>
+ <id>org.maven.ide.eclipse.scala</id>
+ </configurator>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <goals>
+ <goal>add-source</goal>
+ <goal>doc</goal>
+ <goal>genjson</goal>
+ <goal>run</goal>
+ <goal>script</goal>
+ </goals>
+ <versionRange>[3.0,)</versionRange>
+ </pluginExecutionFilter>
+ <action>
+ <execute />
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <goals>
+ <goal>console</goal>
+ <goal>cc</goal>
+ <goal>cctest</goal>
+ <goal>help</goal>
+ </goals>
+ <versionRange>[3.0,)</versionRange>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ <!-- maven-scala-plugin -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.scala-tools</groupId>
View
86 org.maven.ide.eclipse.scala/src/org/maven/ide/eclipse/scala/ScalaProjectConfigurator.java
@@ -34,7 +34,6 @@
import org.eclipse.m2e.jdt.IClasspathEntryDescriptor;
import org.eclipse.m2e.jdt.IJavaProjectConfigurator;
-
//TODO check the jre/java version compliance (>= 1.5)
//TODO check JDT Weaving is enabled (if not enabled, icon of scala file is [J] same as java (and property of the file display "Type :... Java Source File" )
//TODO check that pom.xml and ScalaLib Container declare the same scala version
@@ -47,13 +46,6 @@
*/
public class ScalaProjectConfigurator extends AbstractProjectConfigurator implements IJavaProjectConfigurator {
- /////////////////////////////////////////////////////////////////////////////
- // STATIC
- /////////////////////////////////////////////////////////////////////////////
-
- private static String MOJO_GROUP_ID = "org.scala-tools";
-
- private static String MOJO_ARTIFACT_ID = "maven-scala-plugin";
private Map<String, Integer> mapSourceTypeWeight;
@@ -102,29 +94,25 @@ private Integer getWeight(IClasspathEntry ce) {
};
}
- /////////////////////////////////////////////////////////////////////////////
- // INSTANCE
- /////////////////////////////////////////////////////////////////////////////
-
private String scalaNatureId() {
ScalaPluginIds ids = Activator.getInstance().scalaPluginIds();
- return (ids == null) ? null : ids.natureId;
+ return (ids == null)?null : ids.natureId;
}
private String scalaLibId() {
ScalaPluginIds ids = Activator.getInstance().scalaPluginIds();
- return (ids == null) ? null : ids.containerLibId;
+ return (ids == null)?null : ids.containerLibId;
}
@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
String scalaNature = scalaNatureId();
- if(scalaNature == null) {
+ if (scalaNature == null) {
//TODO show an alert to user that he should to install scala-ide plugin;
return;
}
try {
- if(request != null) {
+ if (request != null) {
IProject project = request.getProject();
if(!project.hasNature(scalaNature) && isScalaProject(request.getMavenProjectFacade(), monitor)) {
addNature(project, scalaNature, monitor);
@@ -138,19 +126,18 @@ public void configure(ProjectConfigurationRequest request, IProgressMonitor moni
/**
* configure Classpath : contain of "Maven Dependencies" Librairies Container.
*/
- public void configureClasspath(IMavenProjectFacade facade, IClasspathDescriptor classpath, IProgressMonitor monitor)
- throws CoreException {
+ public void configureClasspath(IMavenProjectFacade facade, IClasspathDescriptor classpath, IProgressMonitor monitor) throws CoreException {
String scalaNature = scalaNatureId();
- if(scalaNature == null) {
+ if (scalaNature == null) {
//TODO show an alert to user that he should to install scala-ide plugin;
return;
}
- if(!isLaunchConfigurationCtx()) {
+ if (!isLaunchConfigurationCtx()) {
IProject project = facade.getProject();
if(isScalaProject(project)) {
- // if(!project.hasNature(ID_NATURE)) {
- // addNature(project, ID_NATURE, monitor);
- // }
+ // if(!project.hasNature(ID_NATURE)) {
+ // addNature(project, ID_NATURE, monitor);
+ // }
removeScalaFromMavenContainer(classpath);
addDefaultScalaSourceDirs(facade, classpath, monitor);
sortContainerScalaJre(project, monitor); //
@@ -160,32 +147,31 @@ public void configureClasspath(IMavenProjectFacade facade, IClasspathDescriptor
/**
* To work as maven-scala-plugin, src/main/scala and src/test/scala are added if directory exists
- *
+ *
* @param facade
* @throws CoreException
*/
//TODO take a look at http://github.com/sonatype/m2eclipse-extras/blob/master/org.maven.ide.eclipse.temporary.mojos/src/org/maven/ide/eclipse/buildhelper/BuildhelperProjectConfigurator.java
- private void addDefaultScalaSourceDirs(IMavenProjectFacade facade, IClasspathDescriptor classpath,
- IProgressMonitor monitor) throws CoreException {
+ private void addDefaultScalaSourceDirs(IMavenProjectFacade facade, IClasspathDescriptor classpath, IProgressMonitor monitor) throws CoreException {
IProject project = facade.getProject();
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
int initSize = rawClasspath.length;
// can't use classpath.addSourceEntry because source entry are append under "Maven Dependencies" container
IFolder defaultMainSrc = project.getFolder("src/main/scala");
- if(defaultMainSrc != null && defaultMainSrc.exists()) {
+ if (defaultMainSrc != null && defaultMainSrc.exists()) {
IPath p = defaultMainSrc.getFullPath();
rawClasspath = addSourceEntry(rawClasspath, p, facade.getOutputLocation());
}
IFolder defaultTestSrc = project.getFolder("src/test/scala");
- if(defaultTestSrc != null && defaultTestSrc.exists()) {
+ if (defaultTestSrc != null && defaultTestSrc.exists()) {
IPath p = defaultTestSrc.getFullPath();
rawClasspath = addSourceEntry(rawClasspath, p, facade.getTestOutputLocation());
}
- if(rawClasspath.length != initSize) {
+ if (rawClasspath.length != initSize) {
javaProject.setRawClasspath(rawClasspath, monitor);
}
@@ -200,17 +186,18 @@ private void addDefaultScalaSourceDirs(IMavenProjectFacade facade, IClasspathDes
new IPath[0], //
new IPath[0], //
outputLocation, //
- new IClasspathAttribute[0]);
- if(!contains(rawClasspath, entry)) {
+ new IClasspathAttribute[0]
+ );
+ if (!contains(rawClasspath, entry)) {
back = add(rawClasspath, entry);
}
return back;
}
private boolean contains(IClasspathEntry[] rawClasspath, IClasspathEntry entry) {
- if(entry != null && rawClasspath != null) {
+ if (entry != null && rawClasspath != null) {
for(IClasspathEntry e : rawClasspath) {
- if(entry.equals(e)) {
+ if (entry.equals(e)) {
return true;
}
}
@@ -231,9 +218,12 @@ private void removeScalaFromMavenContainer(IClasspathDescriptor classpath) {
public boolean accept(IClasspathEntryDescriptor descriptor) {
boolean back = "org.scala-lang".equals(descriptor.getGroupId());
//TODO, use content of Scala Library Container instead of hardcoded value
- back = back && ("scala-library".equals(descriptor.getArtifactId())
- //|| "scala-compiler".equals(descriptor.getArtifactId())
- || "scala-dbc".equals(descriptor.getArtifactId()) || "scala-swing".equals(descriptor.getArtifactId()));
+ back = back && (
+ "scala-library".equals(descriptor.getArtifactId())
+ //|| "scala-compiler".equals(descriptor.getArtifactId())
+ || "scala-dbc".equals(descriptor.getArtifactId())
+ || "scala-swing".equals(descriptor.getArtifactId())
+ );
return back;
}
});
@@ -263,12 +253,12 @@ public boolean accept(IClasspathEntryDescriptor descriptor) {
// }
// }
+
/**
- * Not called with m2eclipse 0.10.0 Configure the eclipse project classpath (similar to eclipse
- * IJavaProject.getRawClasspath).
+ * Not called with m2eclipse 0.10.0
+ * Configure the eclipse project classpath (similar to eclipse IJavaProject.getRawClasspath).
*/
- public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath,
- IProgressMonitor monitor) throws CoreException {
+ public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath, IProgressMonitor monitor) throws CoreException {
// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
// IProject project = request.getProject();
// if(isScalaProject(project)) {
@@ -279,9 +269,9 @@ public void configureRawClasspath(ProjectConfigurationRequest request, IClasspat
}
/**
- * Check and reorder Containers : "Scala Lib" should be before "JRE Sys", else 'Run Scala Application' set Boot
- * Entries JRE before Scala and failed with scala.* NotFound Exception. Should already be done when adding nature
- *
+ * Check and reorder Containers : "Scala Lib" should be before "JRE Sys",
+ * else 'Run Scala Application' set Boot Entries JRE before Scala and failed with scala.* NotFound Exception.
+ * Should already be done when adding nature
* @see scala.tools.eclipse.Nature#configure()
*/
private void sortContainerScalaJre(IProject project, IProgressMonitor monitor) throws CoreException {
@@ -303,7 +293,8 @@ private boolean isScalaProject(IProject project) {
}
}
- private boolean isScalaProject(IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
+ private boolean isScalaProject(IMavenProjectFacade facade, IProgressMonitor monitor)
+ throws CoreException {
List<Plugin> plugins = facade.getMavenProject(monitor).getBuildPlugins();
if(plugins != null) {
for(Plugin plugin : plugins) {
@@ -316,8 +307,8 @@ private boolean isScalaProject(IMavenProjectFacade facade, IProgressMonitor moni
}
protected boolean isLaunchConfigurationCtx() {
- for(StackTraceElement e : Thread.currentThread().getStackTrace()) {
- if("launch".equals(e.getMethodName())) {
+ for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
+ if ("launch".equals(e.getMethodName())) {
return true;
}
}
@@ -333,7 +324,8 @@ private boolean isMavenBundlePluginMojo(Plugin plugin) {
}
private boolean isMavenBundlePluginMojo(String groupId, String artifactId) {
- return MOJO_GROUP_ID.equals(groupId) && MOJO_ARTIFACT_ID.equals(artifactId);
+ return ("org.scala-tools".equals(groupId) && "maven-scala-plugin".equals(artifactId))
+ || ("net.alchim31.maven".equals(groupId) && "scala-maven-plugin".equals(artifactId));
}
}
View
6 samples/prj-custom-layout/pom.xml
@@ -29,9 +29,9 @@
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.15.2</version>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.0.1</version>
<executions>
<execution>
<id>scala-compile-first</id>
View
6 samples/prj-java-test-in-scala/pom.xml
@@ -28,9 +28,9 @@
<build>
<plugins>
<plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.15.2</version>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.0.1</version>
<executions>
<execution>
<goals>
View
44 samples/prj-liftbased/pom.xml
@@ -22,28 +22,6 @@
<vscaladoc.links.liftweb.baseurl>http://scala-tools.org/mvnsites-snapshots/liftweb</vscaladoc.links.liftweb.baseurl>
</properties>
- <repositories>
- <repository>
- <id>scala-tools.releases</id>
- <name>Scala-Tools Dependencies Repository for Releases</name>
- <url>http://scala-tools.org/repo-releases</url>
- </repository>
- <repository>
- <id>scala-tools.snapshots</id>
- <name>Scala-Tools Dependencies Repository for Snapshots</name>
- <url>http://scala-tools.org/repo-snapshots</url>
- <snapshots/>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>scala-tools.releases</id>
- <name>Scala-Tools Plugins Repository for Releases</name>
- <url>http://scala-tools.org/repo-releases</url>
- </pluginRepository>
- </pluginRepositories>
-
<dependencies>
<dependency>
<groupId>net.liftweb</groupId>
@@ -94,9 +72,9 @@
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.13.1</version>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.0.1</version>
<configuration>
<charset>${project.build.sourceEncoding}</charset>
<jvmArgs>
@@ -174,20 +152,4 @@
</plugin>
</plugins>
</build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.13.1</version>
- <configuration>
- <charset>${project.build.sourceEncoding}</charset>
- <jvmArgs>
- <jvmArg>-Xmx1024m</jvmArg>
- <jvmArg>-DpackageLinkDefs=file://${project.build.directory}/packageLinkDefs.properties</jvmArg>
- </jvmArgs>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
</project>
View
7 samples/prj-scala-after-java/pom.xml
@@ -26,10 +26,9 @@
<build>
<plugins>
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.15.2</version>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.0.1</version>
<executions>
<execution>
<goals>
View
42 samples/prj-scala-cycle-java/pom.xml
@@ -27,27 +27,27 @@
<build>
<plugins>
<plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.15.2</version>
- <executions>
- <execution>
- <id>scala-compile-first</id>
- <phase>process-resources</phase>
- <goals>
- <goal>add-source</goal>
- <goal>compile</goal>
- </goals>
- </execution>
- <execution>
- <id>scala-test-compile</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.0.1</version>
+ <executions>
+ <execution>
+ <id>scala-compile-first</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>add-source</goal>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>scala-test-compile</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
View
14 samples/prj-scala-only/pom.xml
@@ -14,14 +14,6 @@
<scala.version>2.9.0-1</scala.version>
</properties>
- <repositories>
- <repository>
- <id>scala-tools.org</id>
- <name>Scala-Tools Maven2 Repository</name>
- <url>http://scala-tools.org/repo-releases</url>
- </repository>
- </repositories>
-
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
@@ -64,9 +56,9 @@
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.15.2</version>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.0.1</version>
<executions>
<execution>
<goals>

0 comments on commit dc9b646

Please sign in to comment.
Something went wrong with that request. Please try again.