<project>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>mindplot</artifactId>
    <packaging>jar</packaging>
    <name>Mindmap Draw JavaScript Library</name>

    <parent>
        <groupId>org.wisemapping</groupId>
        <artifactId>wisemapping</artifactId>
        <relativePath>../pom.xml</relativePath>
        <version>3.1-SNAPSHOT</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.wisemapping</groupId>
            <artifactId>web2d</artifactId>
            <version>${com.wisemapping.version}</version>
            <scope>runtime</scope>
        </dependency>
        <!-- <dependency>
            <groupId>com.google.jstestdriver</groupId>
            <artifactId>maven-jstestdriver-plugin</artifactId>
            <version>1.2.2-SNAPSHOT</version>
            <scope>test</scope>
        </dependency> -->
    </dependencies>

    <repositories>
        <repository>
            <id>jstd-maven-plugin google code repo</id>
            <url>http://jstd-maven-plugin.googlecode.com/svn/maven2</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.4</version>

                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <source>
                                def outdir = new File(project.basedir, 'src/main/javascript');
                                if (project.packaging != 'pom')
                                {
                                def dir = new File(project.basedir, 'src/main/resources/');

                                dir.eachFile { file ->
                                def matcher = file.name =~ /messages_(.+)\.properties/;
                                def lang = matcher[0][1];
                                def outfile = new File(outdir, "MessageBundle_${lang}.js");
                                println "Converting ${file.name} to ${outfile.name}";

                                outfile.withWriter('UTF-8') { out ->
                                out.writeLine "mindplot.Messages.BUNDLES['${lang.toLowerCase()}'] = { ";
                                file.eachLine('UTF-8') { line ->
                                if( line.trim()!="" &amp;&amp; line[0]!='#' ) {
                                  matcher = line =~ /(.+)=(.+)/;
                                  out.writeLine("'${matcher[0][1]}' : \"${matcher[0][2]}\",");
                                }
                                }
                                out.writeLine("'DUMMY' : '' ");
                                out.writeLine "};"
                                }
                                }
                                }
                            </source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>merge-js-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <copy toDir="${basedir}/target/classes/">
                                    <fileset dir="${basedir}/src/main/javascript/">
                                        <include name="libraries/**/*"/>
                                        <include name="widget/colorPalette.*"/>
                                        <include name="widget/*.css"/>
                                    </fileset>
                                </copy>
                            </tasks>
                        </configuration>

                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>compress</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>${basedir}/src/main/javascript</sourceDirectory>
                            <outputDirectory>${basedir}/target/compress/</outputDirectory>
                            <nosuffix>true</nosuffix>
                            <excludes>
                                <exclude>libraries/**/*.js</exclude>
                            </excludes>
                            <aggregations>
                                <aggregation>
                                    <output>${project.build.directory}/classes/mindplot-min.js</output>
                                    <inputDir>${basedir}/target/compress</inputDir>
                                    <includes>
                                        <include>header.js</include>
                                        <include>${basedir}/../web2d/target/classes/web2d.svg-min.js</include>
                                        <include>Messages.js</include>
                                        <include>TopicEventDispatcher.js</include>
                                        <include>model/IMindmap.js</include>
                                        <include>model/Mindmap.js</include>
                                        <include>model/INodeModel.js</include>
                                        <include>model/NodeModel.js</include>
                                        <include>model/RelationshipModel.js</include>
                                        <include>ActionDispatcher.js</include>
                                        <include>StandaloneActionDispatcher.js</include>
                                        <include>DesignerModel.js</include>
                                        <include>Designer.js</include>
                                        <include>ScreenManager.js</include>
                                        <include>Workspace.js</include>
                                        <include>ShrinkConnector.js</include>
                                        <include>DesignerKeyboard.js</include>
                                        <include>TopicStyle.js</include>
                                        <include>NodeGraph.js</include>
                                        <include>Topic.js</include>
                                        <include>CentralTopic.js</include>
                                        <include>MainTopic.js</include>
                                        <include>DragTopic.js</include>
                                        <include>DragManager.js</include>
                                        <include>DragPivot.js</include>
                                        <include>ConnectionLine.js</include>
                                        <include>Relationship.js</include>
                                        <include>DragConnector.js</include>
                                        <include>TextEditor.js</include>
                                        <include>MultilineTextEditor.js</include>
                                        <include>TextEditorFactory.js</include>
                                        <include>util/Shape.js</include>
                                        <include>util/FadeEffect.js</include>
                                        <include>persistence/ModelCodeName.js</include>
                                        <include>persistence/XMLSerializer_Pela.js</include>
                                        <include>persistence/XMLSerializer_Tango.js</include>
                                        <include>persistence/Pela2TangoMigrator.js</include>
                                        <include>persistence/XMLSerializer_Beta.js</include>
                                        <include>persistence/Beta2PelaMigrator.js</include>
                                        <include>persistence/XMLSerializerFactory.js</include>
                                        <include>PersistenceManager.js</include>
                                        <include>RestPersistenceManager.js</include>
                                        <include>LocalStorageManager.js</include>
                                        <include>EditorProperties.js</include>
                                        <include>IconGroup.js</include>
                                        <include>Icon.js</include>
                                        <include>LinkIcon.js</include>
                                        <include>NoteIcon.js</include>
                                        <include>ActionIcon.js</include>
                                        <include>ImageIcon.js</include>
                                        <include>model/FeatureModel.js</include>
                                        <include>model/IconModel.js</include>
                                        <include>model/LinkModel.js</include>
                                        <include>model/NoteModel.js</include>
                                        <include>Command.js</include>
                                        <include>DesignerActionRunner.js</include>
                                        <include>DesignerUndoManager.js</include>
                                        <include>ControlPoint.js</include>
                                        <include>EditorOptions.js</include>
                                        <include>RelationshipPivot.js</include>
                                        <include>TopicFeature.js</include>
                                        <include>commands/GenericFunctionCommand.js</include>
                                        <include>commands/DeleteCommand.js</include>
                                        <include>commands/DragTopicCommand.js</include>
                                        <include>commands/AddTopicCommand.js</include>
                                        <include>commands/ChangeFeatureToTopicCommand.js</include>
                                        <include>commands/RemoveFeatureFromTopicCommand.js</include>
                                        <include>commands/AddFeatureToTopicCommand.js</include>
                                        <include>commands/AddRelationshipCommand.js</include>
                                        <include>commands/MoveControlPointCommand.js</include>
                                        <include>widget/ModalDialogNotifier.js</include>
                                        <include>widget/ToolbarNotifier.js</include>
                                        <include>widget/ToolbarItem.js</include>
                                        <include>widget/ToolbarPaneItem.js</include>
                                        <include>widget/NoteEditor.js</include>
                                        <include>widget/LinkEditor.js</include>
                                        <include>widget/FloatingTip.js</include>
                                        <include>widget/LinkIconTooltip.js</include>
                                        <include>widget/KeyboardShortcutTooltip.js</include>
                                        <include>widget/ColorPalettePanel.js</include>
                                        <include>widget/ListToolbarPanel.js</include>
                                        <include>widget/FontFamilyPanel.js</include>
                                        <include>widget/FontSizePanel.js</include>
                                        <include>widget/TopicShapePanel.js</include>
                                        <include>widget/IconPanel.js</include>
                                        <include>widget/IMenu.js</include>
                                        <include>widget/Menu.js</include>
                                        <include>TopicFeature.js</include>
                                        <include>layout/EventBusDispatcher.js</include>
                                        <include>layout/ChangeEvent.js</include>
                                        <include>layout/LayoutManager.js</include>
                                        <include>layout/Node.js</include>
                                        <include>layout/RootedTreeSet.js</include>
                                        <include>layout/ChildrenSorterStrategy.js</include>
                                        <include>layout/AbstractBasicSorter.js</include>
                                        <include>layout/BalancedSorter.js</include>
                                        <include>layout/SymmetricSorter.js</include>
                                        <include>layout/GridSorter.js</include>
                                        <include>layout/OriginalLayout.js</include>
                                        <include>layout/EventBus.js</include>
                                        <include>MessageBundle_en.js</include>
                                        <include>MessageBundle_es.js</include>
                                        <include>MessageBundle_de.js</include>
                                        <include>MessageBundle_fr.js</include>
                                        <include>MessageBundle_pt_BR.js</include>
                                        <include>MessageBundle_zh_CN.js</include>
                                        <include>MessageBundle_zh_TW.js</include>
                                        <include>MessageBundle_ca.js</include>
                                        <include>footer.js</include>
                                    </includes>
                                </aggregation>
                            </aggregations>
                            <jswarn>false</jswarn>
                            <force>false</force>
                            <encoding>UTF-8</encoding>
                            <statistics>false</statistics>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>