0

I was trying to convert old java projects into maven build, but facing difficulties excluding source files:

when I set goal to install for the parent project to compile and build jar files for all the projects, it still tries to compile the mentioned excluded java file. Below is my pom.xml for that project:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.app</groupId>
    <artifactId>CCAPS.Impl</artifactId>
    <version>1.0.0</version>

    <parent>
        <groupId>com.app</groupId>
        <artifactId>parent</artifactId>
        <version>1.0</version>
        <relativePath>../Maven.Convertion/parent</relativePath>
    </parent>

    <properties>
        ...
    </properties>

    <dependencies>
        ...
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/adjudication/mapper/BusinessAddendumItemDBOMapper.java</exclude>
                        <exclude>**/adjudication/mapper/ContactInfoDBOMapper.java</exclude>
                        <exclude>**/adjudication/mapper/IncomeDBOMapper.java</exclude>
                        <exclude>**/adjudication/mapper/IncomeItemDBOMapper.java</exclude>
                        <exclude>**/adjudication/mapper/InternationalAddressDBOMapper.java</exclude>
                        <exclude>**/adjudication/mapper/ReferralSourceDBOMapper.java</exclude>
                        <exclude>**/adjudication/interceptor/*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
        <sourceDirectory>${project.basedir}/src/net/ccapsws/ds/adjudication</sourceDirectory>
    </build>
</project>

Last line for exclude is where the error throws when compiling:

[ERROR] \Maven Convertion\CCAPSAdjudication\DataSource.CCAPS.Impl\src\net\gc\ccapsws\ds\adjudication\interceptor\CCAPSDTOAuditInterceptor.java:[8,46] error: package net.ccapsws.validation.dictionary does not exist

The thing is I tried with the exclude declaration but since the src path is custom (${project.basedir}/src/net/ccapsws/ds/adjudicationm, for example, is the src path), I suspect maven doesn't recognize the path? Anyone can help with this?

NOTE that I'm not asking resource files, I want to compile files inside src folder but also willing to exclude specific java files during compilation.

EDIT: There's one another project referencing this project, but in the parent POM I'm putting that project after this project in the reactor sequence, so I don't think anywhere else is referencing this project.

Paul
  • 39
  • 1
  • 12
  • does this mean you want to compile only files in "/src/net/ccapsws/ds/adjudication" and exclude every thing else – ravthiru Jan 17 '17 at 22:57
  • @ravthiru Yes and no. I wanna compile files in src/...../adjudication, but want to exclude files in the exclude tags in my POM, espectially /adjudication/interceptor/*.java where it's still trying to compile. – Paul Jan 17 '17 at 23:05
  • 1
    If the excluded packages are used in the other packages(which are not excluded), then even the excluded packages get compiled because of dependency. – ravthiru Jan 17 '17 at 23:31
  • If sound you should move that code which you like to exclude into a separate module... – khmarbaise Jan 18 '17 at 07:39
  • @ravthiru: I checked the whole working set, none of other code/projects/packages are referencing the specific folder, I do however have a parent POM defining maven compilation plugin, but not declaring anything to exclude, is that the reason? – Paul Jan 18 '17 at 14:31
  • @khmarbaise Not getting what you meant, it is now a package inside the project, but I'm not defining packages in the POM. – Paul Jan 18 '17 at 14:58

1 Answers1

0

The path issue looks similar to the problem answered by these links: https://stackoverflow.com/a/25262893/4055837 and https://stackoverflow.com/a/39450549/4055837

Community
  • 1
  • 1
Sean
  • 56
  • 7
  • Thanks, but as I said, excluding resources will not do the job since I do want to compile the whole project without that specific java file. Resource tag only copies the files. – Paul Jan 18 '17 at 03:23
  • I noticed that, which is why I edited in the two 'answers' to a similar question that deal with paths. It may be that your build job is looking for _adjudication/adjudication_ on the exclusion (I've run into this with Jenkins jobs). – Sean Jan 18 '17 at 18:44
  • Marking this as answer, however the answer itself is not helping, it's the 2 links below the code @Sean posted helped. It's actually the path issue: I mentioned the custom build path already, all I need to add is the trailing path, in my case is ***/interceptor/*.java. Thanks Sean. One more thing, I guess if you have a parent POM setting the compile plugin make sure to have the combine.self="override" stated in configuration tag in your child one. – Paul Jan 18 '17 at 20:11
  • 1
    Also, not sure if this is actually an issue: somewhere else I saw a post about maven having difficulty accepting includes and excludes, I tried with lowering the maven-compiler-plugin down to 2.1 as stated in the thread:http://stackoverflow.com/a/11081252 – Paul Jan 18 '17 at 20:19
  • I'll clean up the answer to reflect where the real help was. Cheers! – Sean Jan 19 '17 at 21:52