Put the Applet on a diet

Post here questions and problems related to oXygen frameworks/document types.
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Put the Applet on a diet

Post by sderrick »

I'm trying to remove excess baggage from the applet which is coming in at +70MB!

We only need text mode to edit TEI/XML documents.

The frameworks jar is 21MB, what can I remove without compromising the applets functionality?

Any other jars I can safely remove?

thanks,

Scott
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Put the Applet on a diet

Post by alex_jitianu »

Hello,

The frameworks.jar contains specific support for a number of XML vocabularies (DITA, TEI etc). Since you are only interested in TEI you can remove all other frameworks from it. You could look for *.framework files and you remove all directories that contain such a file (except for the tei directory). There is another discussion about which jars can be removed from the applet that can help.

Best regards,
Alex
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

I removed most of the framework folders in /bundle-frameworks/oxygen-frameworks

rebuilt the editor and it repopulated the folder and zipped them up into the same 21MB jar as before?

I don't see a listing of the frameworks in the pom file so am unsure as to how to remove them?

Scott
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

I changed the <zip.. contents on the pom file to

<zip destfile="${project.build.directory}/classes/frameworks.zip">
<zipfileset dir="oxygen-frameworks">
<include name="tei/**" />
<exclude name="tei/xml/tei/stylesheet/**" />
<exclude name="tei/xml/teip4/stylesheet/**" />
</zipfileset>
</zip>
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

I changed the <zip.. contents on the pom file to

Code: Select all

<zip destfile="${project.build.directory}/classes/frameworks.zip">
<zipfileset dir="oxygen-frameworks">
<include name="tei/**" />
<exclude name="tei/xml/tei/stylesheet/**" />
<exclude name="tei/xml/teip4/stylesheet/**" />
</zipfileset>
</zip>
and it reduced the jar from 21MB to 9MB

better but seems like it could be reduced further? The TEI framework is half the framework load?

Scott
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

So from the "other" discussion it looks like I don't need all the dependency jars.

The question now is how do I exclude them? maven automagically puts them in the ../jnlp/lib folder

I think from this

Code: Select all

<!-- Copy all dependecy jars to the lib folder of the applet. -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.8</version>
<executions>
<execution>
<id>copy-libs</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jnlp/lib</outputDirectory>
<excludeArtifactIds>bundle-samplefiles,junit</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
I tried different <exclude.. tags but none seemed to stop them from populating the lib folder?

??????
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Put the Applet on a diet

Post by alex_jitianu »

Hello Scott,

The unzipped TEI framework has 42MB. If you have a deeper knowledge than I about what each resource is about you could try and remove from them. For example there are a lot of schema (for different flavours or TEI) and you could just keep the ones that you work with. I see that there is also a jtei_aux and jtei_aux_files that I don't know what they represent and they have 18MB together.

For the second issue you should look in the dependencies area of the pom. There are a number of exclusion there so you can contribute others. If you are using Eclipse you can open the POM file with the Maven POM editor and activate the tab Dependency Hierarchy. There, you can identify the dependencies you don't want and from a contextual menu you can choose Exclude Maven Artifact.... It will have a similar result as you would add the dependencies yourself but it might be faster to identify the artifact IDs.

Code: Select all

		<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-sdk</artifactId>
<version>${oxygen.sdk.version}</version>
<exclusions>
<!-- Remove this exclusion if you want WebDav Support in your application. -->
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<!-- Remove this exclusion if you want MathML rendering in your application
based on Apache Jeuclid. -->
<exclusion>
<artifactId>jeuclid-core</artifactId>
<groupId>net.sourceforge.jeuclid</groupId>
</exclusion>
<!-- oXygen does not support animated SVGs. -->
<exclusion>
<artifactId>batik-js</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<!-- No need for ZIP support in the applet. -->
<exclusion>
<artifactId>truezip</artifactId>
<groupId>de.schlichtherle.io</groupId>
</exclusion>

<!-- TODO Add the exclusions here -->
<!-- ZIP transparent open/save support in applet and webapp, optional -->
<exclusion>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-truezip-6</artifactId>
</exclusion>
</exclusions>
</dependency>
Best regards,
Alex
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

Alex,

this looks good! Great info and a pointer in the right direction!

I'll post my results for those on a similar path.

thanks,

Scott
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

I put this in an exclusion

Code: Select all

<!-- put the editor on a diet! -->
<exclusion>
<artifactId>avalon-framework-api</artifactId>
<groupId>org.apache.avalon</groupId>
</exclusion>
And voila! gone.

Now for he next big question. Any chance there is a list somewhere that says what each of these do? SO I can decide if I need them for TEI, text only editing.

Code: Select all


avalon-framework-impl-4.3.1.jar     icu4j-53.1.jar
batik-anim-1.7.jar java-cup-10k.jar
batik-awt-util-1.7.jar jide-oss-3.6.2.jar
batik-bridge-1.7.jar jna-3.4.0.jar
batik-codec-1.7.jar log4j-1.2.14.jar
batik-css-1.7.jar mbep-editor-applet-1.0-SNAPSHOT.jar
batik-dom-1.7.jar native-hunspell-17.0.0.jar
batik-ext-1.7.jar native-jna-17.0.0.jar
batik-gui-util-1.7.jar native-windows-helper-17.0.0.jar
batik-gvt-1.7.jar nekohtml-1.9.19.jar
batik-parser-1.7.jar oxygen-17.0.0.jar
batik-script-1.7.jar oxygen-jing-17.0.0.jar
batik-svg-dom-1.7.jar oxygen-psychopath-17.0.0.jar
batik-svggen-1.7.jar oxygen-resolver-17.0.0.jar
batik-swing-1.7.jar oxygen-saxon-17.0.0.jar
batik-transcoder-1.7.jar oxygen-saxon9he-17.0.0.jar
batik-util-1.7.jar oxygen-sdk-17.0.0.jar
batik-xml-1.7.jar oxygen-token-markers-obf-17.0.0.jar
bundle-frameworks-1.0-SNAPSHOT.jar oxygen-truezip-6-17.0.0.jar
bundle-options-1.0-SNAPSHOT.jar oxygen-xercesImpl-17.0.0.jar
commons-io-1.1.jar rhino-1.7R5.jar
commons-logging-1.0.4.jar xml-apis-1.4.01.jar
dicts-autocorrect-17.0.0.jar xml-apis-ext-1.3.04.jar
dicts-hunspell-17.0.0.jar xmlgraphics-commons-1.2.jar
fop-0.94.jar
I found this interesting diagrom for batik

Image
https://xmlgraphics.apache.org/batik/im ... -small.svg

thanks

Scott
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Put the Applet on a diet

Post by Radu »

Hi Scott,

So you are interested in Text-only editing, you are creating no Author visual editing mode, right?

Please see a comment for each JAR library below along with advice for removing/keeping it:

Code: Select all

   
batik-anim-1.7.jar (render SVG in Author, advice->remove)
batik-awt-util-1.7.jar (render SVG in Author, advice->remove)
batik-bridge-1.7.jar (render SVG in Author, advice->remove)
batik-codec-1.7.jar (render SVG in Author, advice->remove)
batik-css-1.7.jar (render SVG in Author, advice->remove)
batik-dom-1.7.jar (render SVG in Author, advice->remove)
batik-ext-1.7.jar (render SVG in Author, advice->remove)
batik-gui-util-1.7.jar (render SVG in Author, advice->remove)
batik-gvt-1.7.jar (render SVG in Author, advice->remove)
batik-parser-1.7.jar (render SVG in Author, advice->remove)
batik-script-1.7.jar (render SVG in Author, advice->remove)
batik-svg-dom-1.7.jar (render SVG in Author, advice->remove)
batik-svggen-1.7.jar (render SVG in Author, advice->remove)
batik-swing-1.7.jar (render SVG in Author, advice->remove)
batik-transcoder-1.7.jar (render SVG in Author, advice->remove)
batik-util-1.7.jar (render SVG in Author, advice->remove)
batik-xml-1.7.jar (render SVG in Author, advice->remove)
bundle-frameworks-1.0-SNAPSHOT.jar
bundle-options-1.0-SNAPSHOT.jar
commons-io-1.1.jar rhino-1.7R5.jar
commons-logging-1.0.4.jar xml-apis-1.4.01.jar
dicts-autocorrect-17.0.0.jar (used for auto-correct in Author visual editing mode, advice->remove) xml-apis-ext-1.3.04.jar
dicts-hunspell-17.0.0.jar (used for auto/manual spell checl, advice->keep)
xmlgraphics-commons-1.2.jar (used by Apache FOP library below, advice->remove)
avalon-framework-impl-4.3.1.jar (used by Apache FOP library below, advice->remove)
fop-0.94.jar (used to publish to PDF using Apache FOP, advice->remove)
icu4j-53.1.jar (used as a string comparator by some libraries, advice->remove)

java-cup-10k.jar (no idea, probably comes as a maven dependency)
jide-oss-3.6.2.jar (used from some special Swing component implementation, advice->Keep)
jna-3.4.0.jar (used by spell checker, advice->Keep)
native-hunspell-17.0.0.jar (used by spell checker, advice->Keep)
native-jna-17.0.0.jar (used by spell checker, advice->Keep)
native-windows-helper-17.0.0.jar (used to show a native local file chooser, advice->Probably remove)
nekohtml-1.9.19.jar (used for smart paste in Author mode, advice->Remove)
log4j-1.2.14.jar (logging utility used by many librarie, advice->Keep)
mbep-editor-applet-1.0-SNAPSHOT.jar (main applet library, advice->Keep)
oxygen-17.0.0.jar (main Oxygen functionality library, advice->Keep)
oxygen-jing-17.0.0.jar (used to validate XML with RelaxNG, advice->Keep)
oxygen-psychopath-17.0.0.jar (used by Xerces parser, Advice->Keep)
oxygen-resolver-17.0.0.jar (used by Xerces parser, Advice->Keep)
oxygen-xercesImpl-17.0.0.jar (Xerces XML parser library, advice->Keep
oxygen-saxon-17.0.0.jar (Saxon 6 XSLT processor with patches, used for Schematron validation, advice->Keep)
oxygen-saxon9he-17.0.0.jar (Saxon 9 XSLT processor with patches, used for Schematron validation, advice->Keep)
oxygen-sdk-17.0.0.jar (not sure what's in there)
oxygen-token-markers-obf-17.0.0.jar (used for syntax highlight in text editing mode, advice->Keep)
oxygen-truezip-6-17.0.0.jar (used for editing files directly from ZIP archives, advice->Remove)
Even if I advice that certain libraries should be removed because the functionality will not be used in your component, our code may still indirectly call methods from them so it may still break.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

Radu,

this is perfect. I understand the problem with dependency’s and unintended consequences.

I'll test for problems. after removing the jars. I run with the console open so hopefully if I remove something that is not needed I'll get a warning or error output...

thanks again,

Scott
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Put the Applet on a diet

Post by sderrick »

I reduced the applet from 71MB to 56MB. This is for a Text mode only, editing TEI based xml files. About 20%.

I removed excess frameworks by changing the frameworks configuration in the frameworks.pom to

<zip destfile="${project.build.directory}/classes/frameworks.zip">
<zipfileset dir="oxygen-frameworks">
<include name="tei/**" />
<exclude name="tei/xml/tei/stylesheet/**" />
<exclude name="tei/xml/teip4/stylesheet/**" />
</zipfileset>
</zip>

I added these exclusions in the editor.pom

Code: Select all

                               <!-- put the editor on a diet! -->
<exclusion>
<artifactId>avalon-framework-api</artifactId>
<groupId>org.apache.avalon.framework</groupId>
</exclusion>
<exclusion>
<artifactId>avalon-framework-impl</artifactId>
<groupId>org.apache.avalon.framework</groupId>
</exclusion>
<exclusion>
<artifactId>batik-anim</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-bridge</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-awt-util</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-css</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-dom</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-ext</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-gui-util</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-gvt</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-parser</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-svg-dom</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-svggen</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-swing</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-util</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-xml</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>nekohtml</artifactId>
<groupId>net.sourceforge.nekohtml</groupId>
</exclusion>
<exclusion>
<artifactId>xmlgraphics-commons</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>oxygen-truezip-6</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>dicts-autocorrect</artifactId>
<groupId>*</groupId>
</exclusion>
<!-- excluding any of these breaks the import for org.apache.commons.io.FilenameUtils; ????
<exclusion>
<artifactId>batik-transcoder</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>batik-codec</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>fop</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
-->
for some reason excluding the 3 libs below caused problems importing standard objects like

org.apache.commons.io.FilenameUtils

<artifactId>batik-transcoder</artifactId>
<artifactId>batik-codec</artifactId>
<artifactId>fop</artifactId>
Post Reply