Visualizzazione post con etichetta maven. Mostra tutti i post
Visualizzazione post con etichetta maven. Mostra tutti i post

mercoledì 10 agosto 2011

FLAP is now available as Open Source

A few days ago I created a repository on GitHub to host a few bits of source code: Ferrari Luca's Agent Platform (FLAP). This tiny project is a Java agent platform inspired by Aglets that I used during a course I did at the University of Modena and Reggio Emilia in late 2006. My idea was to present students with a simple agent platform, easy to understand and to debug, in order to make they understand the main concept behind concurrency, thread management and agent messaging a platform must accomplish. The platform represents also a good starting point to do experiments against agent algorithms and theories, and it is for this reason I'm releasing this as Open Source. You are free to experiment and improve the platform as much as you want, but please take into account that the platform is intended to be a didactic workbench, not a professional or complex product. The code compiles with Apache Maven, and if you run test you will actually prompted with a micro interactive shell.

The code is released under the BSD license, so you are really free to do whatever you want with it. But if you find it useful in your courses, studies, free time, please let me know.


sabato 18 giugno 2011

Maven settings: repository path & proxy

La configurazione del processo di compilazione di Maven puo' essere modificata opportunamente mediante il file che si trova in $HOME/.m2/settings.xml. Inizialmente potrebbe essere necessario creare tale file, poiche' Maven non lo inizializza di default. Due personalizzazioni molto utili da inserire in tale file sono:
 
  • localRepository: configura il percorso del repository affinche' non sia, in default, in $HOME/.m2. Questo e' utile quando si vuole, ad esempio, tenere i jar scaricati su una partizione differente (magari condivisa).
  • proxy: consente la configurazione di un proxy, con eventuale autenticazione, per il download delle risorse.

Un esempio di file che utilizza entrambe le funzioni di cui sopra e' il seguente:



 <settings>

  <localRepository>/sviluppo/java/jars</localRepository>


  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>192.168.1.76</host>
      <port>8080</port>
      <username>luca</username>
      <password>password</password>
    </proxy>
  </proxies>

</settings>

mercoledì 15 giugno 2011

Maven & Log4J: dependency error

Maven e' un ottimo sistema di compilazione/configurazione di un progetto Java, e la scelta di usare degli artifacts che vengono scaricati e configurati automaticamente e' veramente eccellente. Mai mi sarei aspettato di ottenere un errore piuttosto criptico da un progetto molto semplice che richiedeva la presenza di log4j. Eseguendo il processo di compilazione ottenevo l'errore:

[ERROR] Failed to execute goal on project XYZ: Could not resolve dependencies for project XYZ:XYZ:jar:0.2-STABLE: The following artifacts could not be resolved: com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact com.sun.jdmk:jmxtools:jar:1.2.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories WagonRepositoryConnectorFactory


Ebbene l'errore di cui sopra e' generato dall'impossibilita' di scaricare alcuni jar dal sito di java.net, ma a parte questo, essendo il mio progetto molto semplice, tali jar non erano nemmeno richiesti! Il problema e' nelle dipendenze di Log4J che dalla versione 1.2.15 hanno delle dipendenze sui suddetti package. Ma se tali package non vengono usati e' possibile escluderli dal processo di compilazione/download modificando il file pom come segue:

<dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.15</version>
      <scope>compile</scope>
<exclusions>
    <exclusion>
      <groupId>javax.mail</groupId>
      <artifactId>mail</artifactId>
    </exclusion>
    <exclusion>
      <groupId>javax.jms</groupId>
      <artifactId>jms</artifactId>
    </exclusion>
    <exclusion>
      <groupId>com.sun.jdmk</groupId>
      <artifactId>jmxtools</artifactId>
    </exclusion>
    <exclusion>
      <groupId>com.sun.jmx</groupId>
      <artifactId>jmxri</artifactId>
    </exclusion>
  </exclusions>

    </dependency>


Con questa modifica la compilazione di progetti che richiedono le funzionalita' "standard" di Log4J avverra' senza problemi.

martedì 14 giugno 2011

JFK update: Maven setup

After a few commits to make JFK available as an Apache Ant based project  I decided to switch to the more useful Apache Maven. Now JFK has a Maven pom.xml file that allows for compilation, downloading of dependencies and test execution.
To compile the project just type:
  
   mvn compile

and the system will start download dependencies and all required jars to compile the project. To run the tests just type:

    mvn test

Note that within this commit the repository layout has changed in order to respect the Maven structure; in particular:
  • -the "src" folder now has "main" for the JFK code and "test" for the test suite;
  • the "src/main/resource" folder is the one that contains the log4j and spring configuration XML files;
  • the above XML files have changed name: "jfk.log4j.xml" and "jfk.spring-beans.xml"


lunedì 13 giugno 2011

WhiteCat & Maven

In the last days I spent a few hours refactoring the WhiteCat source tree in order to be compliant with Apache Maven. Now it is possible to download the tree and have Maven to compile and run the test suite without having to worry about manually set up dependencies and jar files.

To compile the tree just type

mvn compile
while to run all the tests just run

mvn test

It is worth noting that this refactoring has allowed me to discovered a few bugs that have been fixed.