Class Resource

java.lang.Object
org.robovm.compiler.config.Resource

public class Resource
extends Object
Specifies resources needed by the application the compiler produces. A resource can be specified using a single File:
 <resource>path/to/the/resource.txt</resource>
 
If the path specifies a directory the directory including its contents (except for the default excludes, see below) will be copied. If the path specifies a file, that file will be copied.

A resource be also be specified with a base directory, a target path and include and exclude filters (similar to Maven's <resource> element):

 <resource>
   <targetPath>data</targetPath>
   <directory>resources</directory>
   <includes>
     <include>**/*</include>
   </includes>
   <excludes>
     <exclude>**/*.bak</exclude>
   </excludes>
   <flatten>false</flatten>
   <ignoreDefaultExcludes>false</ignoreDefaultExcludes>
   <skipPngCrush>false</skipPngCrush>
 </resource>
 
Each element represents a property in this class. Please see the documentation for each property's getter method for more information.

The current Target may transform and rename a resource while being copied (e.g. running pngcrush or converting xib files to nib files).

Default excludes

(The same as those used by ANT 1.9)

Miscellaneous typical temporary files:

  • **/*~
  • **/#*#
  • **/.#*
  • **/%*%
  • **/._*
CVS:
  • **/CVS
  • **/CVS/**
  • **/.cvsignore
SCCS:
  • **/SCCS
  • **/SCCS/**
Visual SourceSafe:
  • **/vssver.scc
Subversion:
  • **/.svn
  • **/.svn/**
Git:
  • **/.git
  • **/.git/**
  • **/.gitattributes
  • **/.gitignore
  • **/.gitmodules
Mercurial:
  • **/.hg
  • **/.hg/**
  • **/.hgignore
  • **/.hgsub
  • **/.hgsubstate
  • **/.hgtags
Bazaar:
  • **/.bzr
  • **/.bzr/**
  • **/.bzrignore
Mac:
  • **/.DS_Store

  • Constructor Details

    • Resource

      protected Resource()
    • Resource

      public Resource​(File path)
      Creates a new simple Resource which will copy the specified file or directory.
      Parameters:
      path - the File which will be copied.
    • Resource

      public Resource​(File directory, String targetPath)
      Creates a new Resource which will copy all files in the specified base directory to the specified target path in the application directory.
      Parameters:
      directory - the base directory.
      targetPath - the target path.
  • Method Details

    • getPath

      public File getPath()
      Returns the path which will be copied for simple Resources or null if this isn't a simple Resource.
      Returns:
      the path.
    • getTargetPath

      public String getTargetPath()
      Returns the target path relative to the application directory (i.e. app bundle directory for iOS apps) where paths matching this Resource will be copied. If not specified paths will be copied directly to the application directory.
      Returns:
      the target path or null if not specified.
    • getDirectory

      public File getDirectory()
      Returns the base directory containing the files and directories copied by the Resource.
      Returns:
      the base directory.
    • getIncludes

      public List<String> getIncludes()
      Returns a list of Ant-style patterns (using **, *, ? as wildcards) matching files which will be included when copying this Resource.
      Returns:
      the include patterns.
      See Also:
      AntPathMatcher
    • include

      public Resource include​(String... patterns)
      Adds include patterns.
      Returns:
      this
      See Also:
      getIncludes()
    • getExcludes

      public List<String> getExcludes()
      Returns a list of Ant-style patterns (using **, *, ? as wildcards) matching files which will be excluded when copying this Resource.
      Returns:
      the exclude patterns.
      See Also:
      AntPathMatcher
    • exclude

      public Resource exclude​(String... patterns)
      Adds exclude patterns.
      Returns:
      this
      See Also:
      getExcludes()
    • isFlatten

      public boolean isFlatten()
      Returns true if the files matched by this Resource should be copied directly into the application directory without preserving the directory structure of the source directory. The default is false.
      Returns:
      true if the directory structure should be flattened.
    • flatten

      public Resource flatten​(boolean b)
      Sets the flatten property and returns this.
      Parameters:
      b - the new value.
      Returns:
      this
      See Also:
      isFlatten()
    • isIgnoreDefaultExcludes

      public boolean isIgnoreDefaultExcludes()
      Returns true if the default excludes should be ignored and copied for this Resource. The default is false, i.e. don't copy files matching the default excludes.
      Returns:
      true if default excludes should be ignored.
    • ignoreDefaultExcludes

      public Resource ignoreDefaultExcludes​(boolean b)
      Sets the ignoreDefaultExcludes property and returns this.
      Parameters:
      b - the new value.
      Returns:
      this
      See Also:
      isIgnoreDefaultExcludes()
    • isSkipPngCrush

      public boolean isSkipPngCrush()
      Returns true if pngcrush should not be called for PNG files matching this Resource when targeting iOS. The default is false, i.e. pngcrush WILL be called for PNG files.
      Returns:
      true if pngcrush should not be called.
    • skipPngCrush

      public Resource skipPngCrush​(boolean b)
      Sets the skipPngCrush property and returns this.
      Parameters:
      b - the new value.
      Returns:
      this
      See Also:
      isSkipPngCrush()
    • walk

      public void walk​(Resource.Walker walker) throws IOException
      Throws:
      IOException
    • walk

      public void walk​(Resource.Walker walker, File destDir) throws IOException
      Throws:
      IOException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object