Oracle
 sql >> Database >  >> RDS >> Oracle

dove dovrei mettere le risorse del programma di installazione (file wxs, dmg-script, icona) e come configurare Maven antrun durante la distribuzione di app autonome

Dopo tanti tentativi finalmente ho risolto il mio problema e per aiutare gli altri sto postando qui la soluzione.

La struttura del progetto dovrebbe essere così

e pom.xml dovrebbe essere così

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.client</groupId>
<artifactId>JavaClient</artifactId>
<version>5.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JavaClient</name>

<properties>
    <exec.mainClass>com.client.MainApp</exec.mainClass>
    <javafx.version>2.2.67</javafx.version>
    <fx.home>${java.home}/lib/jfxrt.jar</fx.home>
    <javafx.tools.ant.jar>${java.home}/../lib/ant-javafx.jar</javafx.tools.ant.jar>
    <javafx-dialogs.jar>${project.basedir}/lib/javafx-dialogs-0.0.1.jar</javafx-dialogs.jar>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <dist.dir>${project.build.directory}/deploy</dist.dir>
    <base.dir>${project.basedir}</base.dir>
</properties>

<dependencies>
    <dependency>
        <groupId>org.oracle</groupId>
        <artifactId>javafx</artifactId>
        <version>${javafx.version}</version>
        <systemPath>${fx.home}</systemPath>
        <scope>system</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>xmlpull</groupId>
        <artifactId>xmlpull</artifactId>
        <version>1.1.3.1</version>
    </dependency>

    <dependency>
        <groupId>xpp3</groupId>
        <artifactId>xpp3_min</artifactId>
        <version>1.1.4c</version>
    </dependency>

    <dependency>
        <groupId>com.thoughtworks.xstream</groupId>
        <artifactId>xstream</artifactId>
        <version>1.4.7</version>
    </dependency>

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>javafx-dialogs</artifactId>
        <version>0.0.1</version>
        <scope>system</scope>
        <systemPath>${javafx-dialogs.jar}</systemPath>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.0.2</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <includes>
                    <include>**/*Test.class</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <id>create-temp-jar</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target xmlns:fx="javafx:com.sun.javafx.tools.ant">
                            <taskdef uri="javafx:com.sun.javafx.tools.ant" resource="com/sun/javafx/tools/ant/antlib.xml"
                                classpath="${project.basedir}:${javafx.tools.ant.jar}:${fx.home}" />

                            <fx:jar
                                destfile="${project.build.directory}/${project.build.finalName}-temp">
                                <fx:application id="fxApp" name="${project.name}"
                                    mainClass="${exec.mainClass}" />
                                <fx:fileset dir="${project.build.directory}/classes" />
                                <manifest>
                                    <attribute name="Implementation-Vendor" value="${app.vendor}" />
                                    <attribute name="Implementation-Title" value="${app.name}" />
                                    <attribute name="Implementation-Version" value="1.0" />
                                </manifest>
                            </fx:jar>
                            <attachartifact
                                file="${project.build.directory}/${project.build.finalName}-temp.jar"
                                classifier="temp" />
                        </target>
                    </configuration>
                </execution>
                <execution>
                    <id>create-deployment-bundle</id>
                    <phase>install</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target xmlns:fx="javafx:com.sun.javafx.tools.ant">
                            
                            <taskdef uri="javafx:com.sun.javafx.tools.ant" resource="com/sun/javafx/tools/ant/antlib.xml"
                                classpath="${project.basedir}:${javafx.tools.ant.jar}:${fx.home}" />

                            <fx:deploy nativeBundles="all" width="100" height="100"
                                outdir="${dist.dir}" embedJNLP="true" outfile="${project.build.finalName}"
                                verbose="true">

                                <fx:application name="${project.build.finalName}"
                                    mainClass="${exec.mainClass}" />
                                <fx:resources>
                                    <fx:fileset dir="${project.build.directory}" includes="${project.build.finalName}.jar" />
                                </fx:resources>
                                <fx:info title="${project.build.finalName}" vendor="NUAXIS"
                                    description="Test built from Java executable jar" />

                                <fx:permissions elevated="true" />
                            </fx:deploy>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <descriptors>
                    <descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
                </descriptors>
                <finalName>${project.build.finalName}</finalName>
                <appendAssemblyId>false</appendAssemblyId>
                <archive>
                    <manifestEntries>
                        <JavaFX-Version>${javafx.version}</JavaFX-Version>
                        <JavaFX-Application-Class>${exec.mainClass}</JavaFX-Application-Class>
                        <Main-Class>com/javafx/main/Main</Main-Class>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

Ora ti spiego il mio errore. guarda da vicino la parte build di Question. nel plug-in ant-run quando entriamo in fx:deploy task qui trovi che ho l'ingresso di class-path. ho incasinato questa parte che era così semplice. guarda ora nel mio Pom qui. percorso di classe ora aggiornato. prima menziono la directory di base, quindi il percorso ant-fx-plugin, quindi il percorso jfxrt.jar. jfxrt potrebbe non essere necessario. dopo questo ho rimosso la sezione delle dipendenze del plugin. questo è fondamentale. se non rimuovo questa sezione, il mio plug-in antrun esamina sempre le dipendenze fornite da Maven ma non in ant-classpath. nell'ordine ant-classpath è molto molto importante. il tuo basedir deve sempre venire prima di ant-run.jar . questo è tutto

Spero che questo sarà utile per le persone che dovranno affrontare questo problema.