Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

JFX compiler - Maven plugin
 Post subject: JFX compiler - Maven plugin Post rating: 0   New post Posted: Fri 26 Jan, 2018, 17:08 
User avatar

User rating: 8
Joined: Mon 09 Jun, 2014, 21:07
Posts: 49
Location: Poland, Warsaw
Dear Developers and Traders,

Intro
I would like to share with you custom Maven plugin that facilities packaging of strategies, plugins and indicators to .jfx file directly from your favorite IDE. The plugin is especially helpful if your project consists of many classes and/or external libraries.

Current situation
Without the plugin, if you have a project that contains several classes, your options are two:
1. Keep all classes in one file – terrible to structure your code and navigate around, difficult to keep the code clean.
2. Compile your project in IDE into to a jar file, and then use @Library annotation and link your project with the Strategy file. This forces you to compile things in two places – JForex Platform and your IDE – it is time wasting and error prone.

Plugin advantages
The JFX Packer Maven plugin compiles your project to .jfx file from your IDE level, therefore, the whole development and packing process takes place in the IDE. You use the JForex platform only to run the output (strategy, plugin or indicator).

How to use the plugin
In order to use the plugin you need to update your pom.xml file by two elements:
1. Plugin repository information - required for the project to know where to download the plugin from.
2. Maven-jar-plugin configuration – required to update manifest.mf file to comply with JForex compiler requirements.
3. JFX Packer plugin configuration – the actual plugin confirmation.

Plugin configuration parameters
         <plugin>
            <groupId>eu.smartfx</groupId>
            <artifactId>jfxpacker</artifactId>
            <version>1.0.0</version>
            <executions>
               <execution>
                  <goals>
                     <goal>packToJfx</goal>
                  </goals>
                  <configuration>
                     <inputArtifacts>
                        <artifact>${project.artifactId}-${project.version}</artifact>
                     </inputArtifacts>
                     <!-- optional -->
                     <copyJfxFileTo>c:/Users/Grzegorz/Documents/JForex/Strategies/</copyJfxFileTo>
                     <!-- optional -->
                  </configuration>
               </execution>
            </executions>
         </plugin>

The JFX Packer plugin contains two configuration parameters:
1) Input artifacts – jar file name(s) to be compiled to .jfx file. For example if your project produces a file with following name: my_strategy-1.0.0.jar, then you would put here my_strategy-1.0.0. You can use also maven variables, for example ${project.artifactId}-${project.version}.
2) copyJfxFileTo – .jfx file gets created in the same directory where the original .jar file lies. You can tell the plugin to copy compliled .jfx file to your strategy folder for easy access from JForex platform.

The attachment contains the sample project - Equity Take Profit. There is not much logic behind, it is just to present how to use the plugin. Please, review to better understand how it works.

Hope it will be helpful for your daily activities. Please, let me know your feedback if you find the plugin useful.

All the best
Greg


Attachments:
File comment: version 2 - improved
sample_v2.zip [3.51 KiB]
Downloaded 175 times
sample.zip [22.86 KiB]
Downloaded 148 times
sample.zip [3.53 KiB]
Downloaded 181 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: JFX compiler - Maven plugin Post rating: 0   New post Posted: Fri 26 Oct, 2018, 10:02 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 26
Location: China,
I tested it, but the following exception occurred。。。。
in the NETBEAN 8.2 environment.
exception :
--- maven-jar-plugin:2.4:jar (default-jar) @ sample-project ---
Building jar: D:\sample\target\sample-project-1.0.0.jar

--- jfxpacker:1.0.0:packToJfx (default) @ sample-project ---
Downloading: https://www.dukascopy.com/client/jforexl ... tadata.xml
26, 2018 2:29:43 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
26, 2018 2:29:43 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
: Retrying request to {}->https://www.dukascopy.com:80
26, 2018 2:29:43 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
26, 2018 2:29:43 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
: Retrying request to {}->https://www.dukascopy.com:80
ʮ�� 26, 2018 2:29:43 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 2:29:43 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80

Could not transfer metadata com.dukascopy.dds2:DDS2-jClient-JForex/maven-metadata.xml from/to dc_public (https://www.dukascopy.com/client/jforexlib/publicrepo/): Connection reset
Downloading: https://www.dukascopy.com/client/jforexl ... tadata.xml
ʮ�� 26, 2018 2:29:44 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 2:29:44 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80
ʮ�� 26, 2018 2:29:44 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 2:29:44 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80
ʮ�� 26, 2018 2:29:44 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
26, 2018 2:29:44 org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80

Could not transfer metadata com.dukascopy.api:JForex-API/maven-metadata.xml from/to dc_public (https://www.dukascopy.com/client/jforexlib/publicrepo/): Connection reset
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 5.954s
Finished at: Fri Oct 26 14:29:44 CST 2018
Final Memory: 15M/220M

pom.xml file :

         <?xml version="1.0" encoding="UTF-8"?>
<project   xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
     
   <modelVersion>4.0.0</modelVersion>
   <groupId>eu.smartfx.sample</groupId>
   <artifactId>sample-project</artifactId>
   <version>1.0.0</version>
   <packaging>jar</packaging>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
   </properties>
       <repositories>
      <repository>
         <id>dc_public</id>
         <name>Dukascopy public repository</name>
         <url>https://www.dukascopy.com/client/jforexlib/publicrepo/</url>
      </repository>
   </repositories>
   <build>
      <plugins>

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
               <archive>
                  <manifestEntries>
                     <pluginMainClass>strategies.sample.EquityTP</pluginMainClass>
                  </manifestEntries>
               </archive>
            </configuration>
         </plugin>


         <plugin>
            <groupId>eu.smartfx</groupId>
            <artifactId>jfxpacker</artifactId>
            <version>1.0.0</version>
            <executions>
               <execution>
                  <goals>
                     <goal>packToJfx</goal>
                  </goals>
                  <configuration>
                     <inputArtifacts>
                        <artifact>${my_strategy}-${1.1}</artifact>
                     </inputArtifacts>
                     <!-- optional -->
                     <copyJfxFileTo>d:/Users/Grzegorz/Documents/JForex/Strategies/</copyJfxFileTo>
                     <!-- optional -->
                  </configuration>
               </execution>
            </executions>
         </plugin>

      </plugins>
   </build>

   <dependencies>
      <dependency>
         <groupId>com.dukascopy.dds2</groupId>
         <artifactId>DDS2-jClient-JForex</artifactId>
         <!-- find the latest available version here:
            https://www.dukascopy.com/client/jforexlib/publicrepo/com/dukascopy/dds2/DDS2-jClient-JForex/
         -->
         <version>3.2.19</version>
         <exclusions>
            <exclusion>
               <groupId>org.slf4j</groupId>
               <artifactId>slf4j-jdk14</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      <!-- find the latest available version here:
         https://www.dukascopy.com/client/jforexlib/publicrepo/com/dukascopy/api/JForex-API/
      -->
      <dependency>
         <groupId>com.dukascopy.api</groupId>
         <artifactId>JForex-API</artifactId>
         <version>2.13.43</version>
         <classifier>sources</classifier>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
         <version>1.7.5</version>
         <optional>true</optional>
      </dependency>
      <dependency>
                        <!-- jsoup HTML parser library @ https://jsoup.org/ -->
                       <groupId>org.jsoup</groupId>
                       <artifactId>jsoup</artifactId>
                       <version>1.11.3</version>
                       </dependency>
    <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.11</version>
     <type>jar</type>
    </dependency>
   </dependencies>
       
       

   <pluginRepositories>
      <pluginRepository>
         <id>sfx_public</id>
         <name>smartFX public repository</name>
         <url>https://smartfx.eu/publicrepo/</url>
      </pluginRepository>
   </pluginRepositories>

   
</project>


 
 Post subject: Re: JFX compiler - Maven plugin Post rating: 0   New post Posted: Sat 27 Oct, 2018, 06:28 
User avatar

User rating: 8
Joined: Mon 09 Jun, 2014, 21:07
Posts: 49
Location: Poland, Warsaw
Hi,

As per following site:
https://stackoverflow.com/questions/13220747/maven-exception-during-project-building

you might be ecountering one of following issues:
* network issue (if you are working behind proxy you need to configure maven to use proxy in maven's settings.xml file)
* you are using old maven version, please download the newest one from: https://ftp.ps.pl/pub/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip

On top of that, please update two elements in your pom.xml file:
* <copyJfxFileTo> with path to one that exists on your filesystem, for example to {$user.home}
* <inputArtifacts><artifact> with filename of your jar package, as per your current pom.xml file configuration it should be ${project.artifactId}-${project.version}

Best regards,
Greg


 
 Post subject: Re: JFX compiler - Maven plugin Post rating: 0   New post Posted: Sat 27 Oct, 2018, 10:51 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 26
Location: China,
First of all, thank you for your reply

1) I am working from home net work(no proxy)
2) Strategy development in NetBeans under the maven project , work well,
3) i do not visit https://www.dukascopy.com ,but can visit https://www.dukascopy.com


I think the problem is in the configuration file, but I don't know how to modify it?


 
The Best Answer  Post subject: Re: JFX compiler - Maven plugin Post rating: 0   New post Posted: Sat 27 Oct, 2018, 11:07 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 26
Location: China,
I am very glad that the problem has been solved. I downloaded another file(sample_v2.zip) and it works.

Thank you again, sharing such a good tool is really great! Solve the difficulty of developers writing strategies!


 

Jump to:  

cron
  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com