2020-11-25

Jupyter and Maven

After upgrading Jupyter Lab, I was editing Java files before compiling them with Maven.  To my surprise, I started getting error messages like:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project foo: Compilation failure: Compilation failure: 

[ERROR] /build/src/main/java/foo/bar/.ipynb_checkpoints/Foo-checkpoint.java:[36,8] class Foo is public, should be declared in a file named Foo.java

[ERROR] /build/src/main/java/foo/bar/Foo.java:[36,8] duplicate class: foo.bar.Foo

This happened because Jupyter Lab is auto-saving files (nice!) and Maven is attempting to compile them (not nice).  After much digging around and experimentation, I added the following to my pom.xml file as a child of the project element:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                      <excludes>
                            <exclude>**/.ipynb_checkpoints/**</exclude>
                      </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

No comments:

Post a Comment