You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by PollerJava <ma...@gmx.at> on 2014/01/21 10:24:03 UTC

Maven add resource

Hi,

I would have a question to Maven and additional resources.
I have build a simple Maven project, afterwards I did mvn eclipse:eclipse
and than I imported it into Eclipse.
This all worked fine. 
Afterwards I would like to extend the pom.xml (below) in order to have new
file structure which is in classpath to the existion one: 

src/main/java and
src/test/java

I would like this additional folder structure:
src/main/generated in my Maven project and also in my Eclipse project.
Therefore I have defined src/main/generated into my pom.

My opinion was that if I add it to the pom than it appears at the file
system and also in eclipse after a refresh - but this isn't.
Does anyone know why this is so and what I'am doing wrong?

Thanks a lot and all the best
PollerJava

<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>at.company.app</groupId>
      <artifactId>my-project</artifactId>
      <packaging>jar</packaging>
      <name>my-project</name>
      <url>http://maven.apache.org</url>
     
      <parent>
        <groupId>at.company.app</groupId>
        <artifactId>my-master</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../my-master/pom.xml</relativePath>
      </parent>
     
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
     
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
     
      <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals><goal>add-source</goal></goals>
                        <configuration>
                            <sources>
                                <source>src/main/generated</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
      </build>
     
    </project>



--
View this message in context: http://maven.40175.n5.nabble.com/Maven-add-resource-tp5781977.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven add resource

Posted by Adrien Rivard <ad...@gmail.com>.
I'm not so sure about maven-eclipse-plugin but in m2e,it  only add the
directory to the eclipse classpath if it exists. If the rest of your build
is supposed to create it, try running with 'mvn package eclipse:eclipse' .



On Wed, Jan 22, 2014 at 10:18 AM, PollerJava <ma...@gmx.at> wrote:

> Thanks a lot for your help.
>
> My requirement is to use Eclipse only as Editor and not to use any plugin
> (Actually I don't know why) and a further college of mine does it like I
> described at top but I don't know why it doesn't work for me.
>
> My Maven output is this:
>
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building example-project 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-eclipse-plugin:2.9:clean (default-cli) @ example-project
> ---
> [INFO] Deleting file: .project
> [INFO] Deleting file: .classpath
> [INFO] Deleting file: .wtpmodules
> [INFO]
> [INFO] >>> maven-eclipse-plugin:2.9:eclipse (default-cli) @ example-project
> >>>
> [INFO]
> [INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @
> example-project ---
> [INFO] Source directory:
>
> /home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project/example-project/src/main/generated
> added.
> [INFO]
> [INFO] <<< maven-eclipse-plugin:2.9:eclipse (default-cli) @ example-project
> <<<
> [INFO]
> [INFO] --- maven-eclipse-plugin:2.9:eclipse (default-cli) @ example-project
> ---
> [INFO] Using Eclipse Workspace:
> /home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project
> [INFO] Adding default classpath container:
> org.eclipse.jdt.launching.JRE_CONTAINER
> [INFO] Not writing settings - defaults suffice
> [INFO] Wrote Eclipse project for "example-project" to
>
> /home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project/example-project.
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 2.497s
> [INFO] Finished at: Wed Jan 22 10:08:09 CET 2014
> [INFO] Final Memory: 12M/210M
> [INFO]
> ------------------------------------------------------------------------
>
>
> So there is a line:
>
>  Source directory:
>
> /home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project/example-project/src/main/generated
> added -> but the folder isn't there.
>
> Has anyone any idea what I'am doing wrong?
> Thanks a lot for further help.
>
> All the best,
> Poller
>
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Maven-add-resource-tp5781977p5782014.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Adrien Rivard

Re: Maven add resource

Posted by PollerJava <ma...@gmx.at>.
Thanks a lot for your help.

My requirement is to use Eclipse only as Editor and not to use any plugin
(Actually I don't know why) and a further college of mine does it like I
described at top but I don't know why it doesn't work for me.

My Maven output is this: 

[INFO]                                                                         
[INFO]
------------------------------------------------------------------------
[INFO] Building example-project 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-eclipse-plugin:2.9:clean (default-cli) @ example-project
---
[INFO] Deleting file: .project
[INFO] Deleting file: .classpath
[INFO] Deleting file: .wtpmodules
[INFO] 
[INFO] >>> maven-eclipse-plugin:2.9:eclipse (default-cli) @ example-project
>>>
[INFO] 
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @
example-project ---
[INFO] Source directory:
/home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project/example-project/src/main/generated
added.
[INFO] 
[INFO] <<< maven-eclipse-plugin:2.9:eclipse (default-cli) @ example-project
<<<
[INFO] 
[INFO] --- maven-eclipse-plugin:2.9:eclipse (default-cli) @ example-project
---
[INFO] Using Eclipse Workspace:
/home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project
[INFO] Adding default classpath container:
org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "example-project" to
/home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project/example-project.
[INFO] 
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2.497s
[INFO] Finished at: Wed Jan 22 10:08:09 CET 2014
[INFO] Final Memory: 12M/210M
[INFO]
------------------------------------------------------------------------


So there is a line: 

 Source directory:
/home/myname/EclipseWorkspaces/PlayGround/SpringCXF_Example_Project/example-project/src/main/generated
added -> but the folder isn't there.

Has anyone any idea what I'am doing wrong?
Thanks a lot for further help.

All the best,
Poller





--
View this message in context: http://maven.40175.n5.nabble.com/Maven-add-resource-tp5781977p5782014.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven add resource

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi PollerJava,

> I would like this additional folder structure: src/main/generated in
> my Maven project and also in my Eclipse project.

I suggest using M2E rather than the eclipse:eclipse goal.

With a modern "Eclipse for Java Developers" IDE, Maven support is built in,
and you don't need "eclipse:eclipse" anymore. Just do File > Import >
Existing Maven Project.

To get generated-sources to work, you may also need to follow the
directions here:
http://stackoverflow.com/a/7160614

Regards,
Curtis


On Tue, Jan 21, 2014 at 3:24 AM, PollerJava <ma...@gmx.at> wrote:

> Hi,
>
> I would have a question to Maven and additional resources.
> I have build a simple Maven project, afterwards I did mvn eclipse:eclipse
> and than I imported it into Eclipse.
> This all worked fine.
> Afterwards I would like to extend the pom.xml (below) in order to have new
> file structure which is in classpath to the existion one:
>
> src/main/java and
> src/test/java
>
> I would like this additional folder structure:
> src/main/generated in my Maven project and also in my Eclipse project.
> Therefore I have defined src/main/generated into my pom.
>
> My opinion was that if I add it to the pom than it appears at the file
> system and also in eclipse after a refresh - but this isn't.
> Does anyone know why this is so and what I'am doing wrong?
>
> Thanks a lot and all the best
> PollerJava
>
> <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>at.company.app</groupId>
>       <artifactId>my-project</artifactId>
>       <packaging>jar</packaging>
>       <name>my-project</name>
>       <url>http://maven.apache.org</url>
>
>       <parent>
>         <groupId>at.company.app</groupId>
>         <artifactId>my-master</artifactId>
>         <version>1.0-SNAPSHOT</version>
>         <relativePath>../my-master/pom.xml</relativePath>
>       </parent>
>
>       <properties>
>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>       </properties>
>
>       <dependencies>
>         <dependency>
>           <groupId>junit</groupId>
>           <artifactId>junit</artifactId>
>           <version>3.8.1</version>
>           <scope>test</scope>
>         </dependency>
>       </dependencies>
>
>       <build>
>         <plugins>
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>build-helper-maven-plugin</artifactId>
>                 <executions>
>                     <execution>
>                         <phase>generate-sources</phase>
>                         <goals><goal>add-source</goal></goals>
>                         <configuration>
>                             <sources>
>                                 <source>src/main/generated</source>
>                             </sources>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
>         </plugins>
>       </build>
>
>     </project>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Maven-add-resource-tp5781977.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>