How to exclude files from compilation

1,357 views
Skip to first unread message

braver

unread,
May 21, 2009, 2:00:26 AM5/21/09
to Maven and Scala
When I write new Scala files and they're not yet finished, mvn install
tries to compile them anyways. I've tried to exclude them and created
a subdirectory drafts/ under src/main/... where I put them then tried
to add exclusion to maven-scala-plugin as in

http://maven.apache.org/plugins/maven-compiler-plugin/howto.html

with <exclude>drafts</exclude>, then drafts/*.* or **/drafts/*.*

-- then tried to add the same block for maven-compiler-plugin, still
the same. What's the right way to exclude?

Cheers,
Alexy

braver

unread,
May 28, 2009, 3:38:39 PM5/28/09
to Maven and Scala
OK, #maven folks pointed out that it's maven-scala-plugin which
doesn't respect the <excludes>... Would it make sense to observe
them?

Cheers,
Alexy

Josh Suereth

unread,
May 28, 2009, 3:40:50 PM5/28/09
to maven-a...@googlegroups.com
I'll open an issue and look into it. 

David Bernard

unread,
May 28, 2009, 3:58:57 PM5/28/09
to maven-a...@googlegroups.com
until Josh add the support for excludes (I don't have dev env), workaround : move your draft dir out from src/main/scala dir. eg src/draft.
Question : why running "mvn install" on not yet finished code ?

/davidB

braver

unread,
May 28, 2009, 4:05:18 PM5/28/09
to Maven and Scala
On May 28, 3:58 pm, David Bernard <david.bernard...@gmail.com> wrote:
> until Josh add the support for excludes (I don't have dev env), workaround :
> move your draft dir out from src/main/scala dir. eg src/draft.
> Question : why running "mvn install" on not yet finished code ?

Just a beginner's way! How do you "just" compile? Sometimes I am
tempted to create a simple makefile with things like:

run:
mvn test-compile scala:run -DmainClass=...

-- although now I put the latter in a launcher thanks to your advice.
Still, "make run" is much shorter than even "mvn test-compile
scala:run"! Although since the latter is common for any mavenized
project with a launcher, I can also alias it in my shell to "mrun" or
some such. Perhaps I can do the same with compile...

Cheers,
Alexy

David Bernard

unread,
May 28, 2009, 4:27:57 PM5/28/09
to maven-a...@googlegroups.com
to compile only:
mvn compile

to run test (include compile)
mvn test

to generate jar (inlude compile + run test) :
mvn package

see http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Personnaly I used shell history to avoid retype again

mvn test-compile scala:run -DmainClass=...

there is other possibility (I used it to share command with co-worker), ex using maven profile :
in pom.xml add
  <profiles>
    <profile>
      <id>r</id>
      <build>
        <defaultGoal>antrun:run</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <configuration>
              <tasks>
                <path id="runtime.classpath">
                  <path refid="maven.test.classpath"/>
                </path>
                <property name="runtime_classpath" refid="runtime.classpath"/>
                <!--echo message="runtime classpath: ${runtime_classpath}"/-->
                <exec executable="java">
                  <arg value="-cp"/>
                  <arg path="${runtime_classpath}"/>
                  <arg value="-Xmx=128m"/>
                  <arg value="org.example.MyClass"/>
                </exec>
              </tasks>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

OR with scala:run
    <profile>
      <id>r</id>
      <build>
        <defaultGoal>scala:run</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <configuration>
              <mainClass>org.example.MyClass</mainClass>
              <!-- args are optional -->
              <args>
                <arg>arg1</arg>
              </args>
              <!-- jvmArgs are optional -->
              <jvmArgs>
                <jvmArg>-Xmx128m</jvmArg>
                <jvmArg>-Djava.library.path=...</jvmArg>
             </jvmArgs>
           </configuration>

          </plugin>
        </plugins>
      </build>
    </profile>

to run profile r
mvn -P r
Reply all
Reply to author
Forward
0 new messages