Maven/GWT - How to access resources in the resources folder?

208 views
Skip to first unread message

Magnus

unread,
Apr 13, 2017, 10:07:57 AM4/13/17
to GWT Users
Hello,

I would like to follow the Maven conventions and place my resources into the resources folder.

How can I access a file in the resources folder server-side so that I have an InputStream then?

My projects were created with maven and webAppCreator, and they do not contain a resources folder. So I have to create it.
What's the standard location? src/main/resources?

Thanks
Magnus

Juan Pablo Gardella

unread,
Apr 13, 2017, 11:04:52 AM4/13/17
to GWT Users

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Magnus

unread,
Apr 16, 2017, 9:44:36 AM4/16/17
to GWT Users
Thanks, this describes the standard directory layout.

If the src/main/directory doesn't exist: Can I simply create it or do I also have to declare it somewhere in the pom?

Magnus

Jens

unread,
Apr 16, 2017, 10:07:52 AM4/16/17
to GWT Users

If the src/main/directory doesn't exist: Can I simply create it or do I also have to declare it somewhere in the pom?

Just create it. If you stick to maven conventions like the standard directory layout you do not have to configure it.

-- J.
Message has been deleted

Juan Pablo Gardella

unread,
Apr 17, 2017, 1:25:55 PM4/17/17
to GWT Users
Remove <build> <resources>*</resources> section.

Try to follow maven convention. The resources for GWT web app should be placed in public folder, see http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideDirectoriesPackageConventions 

For ui binder xml files, I put them in java src folder (I can't make Eclipse works if I put in resources folder)

Regards



On Mon, 17 Apr 2017 at 13:30 Magnus <alpine...@gmail.com> wrote:
Ok, I created the directory src/main/resources and added some xml files there.
But they don't get into the jar file...

Below is my pom.xml.
What's wrong?

Magnus

-----

  <modelVersion>4.0.0</modelVersion>
  <groupId>msm.lib.acs</groupId>
  <artifactId>msm-lib-acs</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>msm-lib-acs</name>

  <properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   <maven.compiler.source>1.8</maven.compiler.source>
   <maven.compiler.target>1.8</maven.compiler.target>
  </properties>


  <dependencies>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>

<!--
      <scope>test</scope>
-->
    </dependency>

    <dependency>
     <groupId>javax.mail</groupId>
     <artifactId>javax.mail-api</artifactId>
     <version>1.5.6</version>
    </dependency>

    <dependency>
     <groupId>javax.servlet</groupId>
     <artifactId>javax.servlet-api</artifactId>
     <version>3.1.0</version>
    </dependency>

    <dependency>
     <groupId>com.google.gwt</groupId>
     <artifactId>gwt-user</artifactId>
     <version>2.8.0</version>
     <scope>provided</scope>
    </dependency>

   <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>6.0.6</version>
   </dependency>
   
   <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.0.0</version>
   </dependency>


  </dependencies>

<build>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
    <resource>
      <directory>src/main/java</directory>
      <includes>
        <include>msm/lib/acs/awi/**/*.java</include>
        <!-- <include>msm/lib/acs/**/*.gwt.xml</include> -->
        <include>msm/lib/acs/**/*.xml</include>
        <include>msm/lib/acs/awi/**/*.css</include>
        <include>msm/lib/acs/awi/**/*.png</include>
        <include>msm/lib/acs/awi/**/*.js</include>
      </includes>
    </resource>
  </resources>

  <plugins>
   <!-- generate source for debugging library code -->
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
     <executions>
      <execution>
      <id>attach-sources</id>
      <goals>
        <goal>jar</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <!-- generate javadoc -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-javadoc-plugin</artifactId>
  <executions>
    <execution>
      <id>attach-javadocs</id>
      <goals>
        <goal>jar</goal>
      </goals>
    </execution>
  </executions>
</plugin>
  
  </plugins>

 </build>

</project>

Reply all
Reply to author
Forward
0 new messages