1

I have a compile issue with my project. It's an old web application built with Tapestry.

My problem is that the files with java extension is under "src/main/resources" directory.

I use "Run as > Maven install" on Eclipse. When I build the project from Eclipse those files with ".java" extension are compiled and copied to "WEB-INF/classes/[package]/[name].class". And it's the behaviour I want.

But when I execute "mvm install" from command line this behavior is not taken.

This is my pom.xml

<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.tapestry</groupId>
    <artifactId>project</artifactId> 
    <version>1.0-PROD</version>  
    <packaging>war</packaging>
    <name>project</name> 
    <dependencies>
        <dependency>
            <groupId>fr.project.ws.bms</groupId>
            <artifactId>bms-cxf-rt-bindings</artifactId>
            <version>1.1-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/bms-cxf-rt-bindings-1.1-SNAPSHOT.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>fr.project.ws.bms</groupId>
            <artifactId>bms-bc-api</artifactId>
            <version>1.1-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/bms-bc-api-1.1-SNAPSHOT.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>fr.project.ws.bms</groupId>
            <artifactId>bms-bc-det-api</artifactId>
            <version>1.1-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/bms-bc-det-api-1.1-SNAPSHOT.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>org.apache.tapestry</groupId>
            <artifactId>tapestry-core</artifactId>
            <version>${tapestry-release-version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>
    <build>
        <finalName>upsa</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <optimize>true</optimize>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archiveClasses>true</archiveClasses>

                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>2.0-beta-6</version>
                <configuration>
                    <outputEncoding>iso-8859-15</outputEncoding>
                </configuration>
            </plugin>
        </plugins>


    </build>

    <reporting>
        <!-- Adds a report detailing the components, mixins and base classes defined 
        by this module. -->
        <plugins>
            <plugin>
                <groupId>org.apache.tapestry</groupId>
                <artifactId>tapestry-component-report</artifactId>
                <version>${tapestry-release-version}</version>
                <configuration>
                    <rootPackage>org.apache.tapestry.upsa</rootPackage>
                </configuration>
            </plugin>
            <plugin>

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>

                <configuration>
                    <minmemory>128m</minmemory>
                    <maxmemory>512m</maxmemory>

                </configuration>
            </plugin>
        </plugins>
        <!-- Adds a report detailing the components, mixins and base classes defined 
        by this module. -->
    </reporting>

    <repositories>

        <repository>
            <id>tapestry-snapshots</id>
            <url>http://tapestry.formos.com/maven-snapshot-repository/</url>
        </repository>

        <repository>
            <id>codehaus.snapshots</id>
            <url>http://snapshots.repository.codehaus.org</url>
        </repository>
        <!-- For access to the selenium JARs. -->
        <repository>
            <id>openqa</id>
            <name>OpenQA Maven Repository</name>
            <url>http://maven.openqa.org/</url>
        </repository>

        <repository>
            <id>localhost.nu</id>
            <url>http://www.localhost.nu/java/mvn</url>
        </repository>


    </repositories>

    <pluginRepositories>


        <!-- As above, this can be commented out when access to the snapshot version 
        of a Tapestry Maven plugin is not required. -->
        <pluginRepository>
            <id>tapestry-snapshots</id>
            <url>http://tapestry.formos.com/maven-snapshot-repository/</url>
        </pluginRepository>


    </pluginRepositories>

    <properties>
        <tapestry-release-version>5.0.13</tapestry-release-version>
    </properties>

</project>

So the main question is how to indicate maven to compile .java files in src/main/resources and place it in "WEB-INF/classes/[package]/[name].class" after that.

I already try :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>default-copy-resources</id>
            <phase>process-resources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <overwrite>true</overwrite>
                <outputDirectory>${project.build.directory}/${project.artifactId}/WEB-INF/classes</outputDirectory>
                <resources>
                    <resource>
                        <directory>${project.basedir}/src/main/resources</directory>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

But doesn't do it.

Sofo Gial
  • 697
  • 1
  • 9
  • 20
Aroniaina
  • 1,252
  • 13
  • 31
  • 3
    *My problem is that the files with java extension is under "src/main/resources" directory.* You should not place java source files in the resources folder; that is for static resources, not source code. Java code belongs in "src/main/java". – Elliott Frisch Dec 18 '18 at 11:46
  • maybe a duplicate of [add an extra source directory](https://stackoverflow.com/questions/9752972/how-to-add-an-extra-source-directory-for-maven-to-compile-and-include-in-the-bui) – Conffusion Dec 18 '18 at 12:00
  • 2
    Follow the convention over configuration and put your java source code as already mentioned into `src/main/java` and your test code into `src/test/java` and your resources for production code into `src/main/resources` and for tests into `src/test/resources... – khmarbaise Dec 18 '18 at 12:24
  • Furthermore remove system scope dependencies (deprecated for a long time). Use a repository manager and deploy the artifacts there... – khmarbaise Dec 18 '18 at 12:25
  • Yes, I know that I should not do that but it's someone else who code it and my work is to build the project without Eclipse. – Aroniaina Dec 18 '18 at 12:51
  • 1
    If your goal is to "build the project without Eclipse" then moving the source from src/main/resources to src/main/java fulfils that requirement... Why on earth would you consider hacking the build process up to avoid fixing the project? – John Stringer Dec 18 '18 at 14:21

0 Answers0