Static Resources - groupon/odo GitHub Wiki

Storing static resources in a plugin jar

  1. Create a "resources" directory under src

  2. Put your static files in that directory

  3. Add an entry to the maven-assembly-plugin configuration section of pom.xml as follows. Replace NameHere with a unique name

    <archive>
    	<manifestEntries>
    		<Plugin-Name>NameHere</Plugin-Name>
    	</manifestEntries>
    </archive>
  4. Add an entry to the build configuration section as follows:

    <resources>
    	<resource>
        	<directory>src</directory>
            <includes>
            	<include>resources/**</include>
            </includes>
       </resource>
    </resources>
  5. Compile and assemble package normally

Accessing stored resources

  1. Resources can be accessed through the API as /testproxy/api/resource/NameHere/fileName

    Example HTML embed: <img src="http://localhost:8090/testproxy/api/resource/NameHere/logo-line.jpg"/>

  2. Resource can be accessed in a plugin function using getResourceAsStream on the current class (example classname is MyClass)

    InputStream resource = MyClass.class.getResourceAsStream("/resources/resource1.json");
⚠️ **GitHub.com Fallback** ⚠️