recommendation for configuring the plugin once

32 views
Skip to first unread message

Glen Marchesani

unread,
Jul 17, 2013, 1:14:28 PM7/17/13
to maven-a...@googlegroups.com

Does anyone have suggestions for how to configure the maven-scala-plugin in one parent pom and have it selectively turned on in the child poms.  I have about 40 projects, some java, some scala and some java and scala.  For the projects that contain scala we use zinc but manually configure it per project.  

We would love to be able to find a way to configure it once and share that config between all the projects.  Noting that some projects want this and some don't.  I/we know there is some mvn foo that would do this but haven't had much success so far.  FWIW we have a master pom that all the projects sprout from.

Any suggestions (any assistance is appreciated)?

Here is the plugin config snippet we currently use in each project.

<plugin>

  <groupId>net.alchim31.maven</groupId>
  <artifactId>scala-maven-plugin</artifactId>

  <configuration>
    <recompileMode>incremental</recompileMode>
    <useZincServer>true</useZincServer>
  </configuration>
  <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>



regards,
Glen

Tomer Gabel

unread,
Jul 17, 2013, 3:49:54 PM7/17/13
to maven-a...@googlegroups.com
The easiest way is to have two parent POMs: a root project for the entire module set, and a Scala-specific POM (using the root as parent) to configure the plugin. Java projects then use the root POM and Scala projects use the second, Scala-enabled POM, as parents in both cases. 
--
 
---
You received this message because you are subscribed to the Google Groups "Maven and Scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-and-sca...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David Bernard

unread,
Jul 17, 2013, 6:02:18 PM7/17/13
to Maven and Scala
an other alternative : move the scala specific part (dependencies, build) into a profile to activate is a property is set (eg: scala-enable) and define this property only in project with scala. (not tested)

Regards

Glen Marchesani

unread,
Jul 18, 2013, 10:04:28 AM7/18/13
to maven-a...@googlegroups.com

Thanks Guys,  I am going to try David's first (lower impact if it works).  I will let y'all know what I find.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-and-scala+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Glen Marchesani

unread,
Jul 18, 2013, 10:23:29 AM7/18/13
to maven-a...@googlegroups.com

Okay got it.  In my case using the existence of a src/main/scala folder to activate the profile works like a charm.  So I have this in my parent pom (and no reference to the scala-maven plugin in my child poms).  

Thanks for the assistance.  


Here are the gory details


        <profile>
            <id>scala-enable</id>
            <activation>
                <file>
                    <exists>src/main/scala</exists>
                </file>            
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.alchim31.maven</groupId>
                        <artifactId>scala-maven-plugin</artifactId>
                        <configuration>
                            <recompileMode>incremental</recompileMode>
                            <useZincServer>true</useZincServer>
                            <args>
                              <arg>-feature</arg>
                            </args>
                        </configuration>

                        <executions>
                            <execution>
                                <id>compile</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>

                            <execution>
                                <id>test-compile</id>
                                <goals>
                                    <goal>testCompile</goal>
                                </goals>
                                <phase>test-compile</phase>
                            </execution>

                            <execution>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                            </execution>

                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>     
Reply all
Reply to author
Forward
0 new messages