Re: Building Clojure applications w/ Maven

2011-12-08 Thread Stuart Sierra
Yes, that Stuart Sierra. Thanks. :)

If you want a real Java main method in your compiled Clojure program, you 
need to define a function in your namespace called -main (with a 
preceding hyphen) in addition to using (:gen-class) in the ns declaration.

-S

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Building Clojure applications w/ Maven

2011-12-07 Thread Riccardo
The error shown in Ubuntu, when I try to execute the jar file, is:
Failed to load Main-Class manifest attribute from '...demo.jar' 

I suppose I am missing something in the main structure...

This is the pom:

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/maven-v4_0_0.xsd;
modelVersion4.0.0/modelVersion
groupIdcom.snowtide/groupId
artifactIdeasy-maven/artifactId
packagingjar/packaging
version1.0-demo/version
nameClojure004/name
dependencies
dependency
groupIdorg.clojure/groupId
artifactIdclojure/artifactId
version1.1.0/version
/dependency
dependency
groupIdorg.clojure/groupId
artifactIdclojure-contrib/artifactId
version1.1.0/version
/dependency
/dependencies

build
plugins
plugin
groupIdcom.theoryinpractise/groupId
artifactIdclojure-maven-plugin/artifactId
version1.3.2/version
executions
execution
idcompile-clojure/id
phasecompile/phase
goals
goalcompile/goal
/goals
/execution
/executions
/plugin
/plugins
/build

repositories
repository
idclojure/id
urlhttp://build.clojure.org/releases/url
/repository
/repositories
/project

Thanks!


On Dec 7, 2:34 am, Richard Lyman richard.ly...@gmail.com wrote:
 Can you provide the pom you're using?

 By 'build' do you mean AOT?

 -Rich







 On Tue, Dec 6, 2011 at 3:35 PM, Riccardo riccardo.novie...@gmail.com wrote:
  Hello, I am doing my dissertation project with Clojure and I am using
  Maven to build. It works on REPL and it build successfully, but the
  JAR file doesn't work, it says: Java Exception all the time. Any
  suggestion?

  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with 
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Building Clojure applications w/ Maven

2011-12-07 Thread Matteo Moci
leiningen has a target you can call like this:

lein pom

maybe setting up a fake simple lein project
you can watch how the generated pom is different from yours.

On Wed, Dec 7, 2011 at 1:32 PM, Riccardo riccardo.novie...@gmail.com wrote:
 The error shown in Ubuntu, when I try to execute the jar file, is:
 Failed to load Main-Class manifest attribute from '...demo.jar' 

 I suppose I am missing something in the main structure...

 This is the pom:

 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/maven-v4_0_0.xsd;
    modelVersion4.0.0/modelVersion
    groupIdcom.snowtide/groupId
    artifactIdeasy-maven/artifactId
    packagingjar/packaging
    version1.0-demo/version
    nameClojure004/name
    dependencies
        dependency
            groupIdorg.clojure/groupId
            artifactIdclojure/artifactId
            version1.1.0/version
        /dependency
        dependency
            groupIdorg.clojure/groupId
            artifactIdclojure-contrib/artifactId
            version1.1.0/version
        /dependency
    /dependencies

    build
        plugins
            plugin
                groupIdcom.theoryinpractise/groupId
                artifactIdclojure-maven-plugin/artifactId
                version1.3.2/version
                executions
                    execution
                        idcompile-clojure/id
                        phasecompile/phase
                        goals
                            goalcompile/goal
                        /goals
                    /execution
                /executions
            /plugin
        /plugins
    /build

    repositories
        repository
            idclojure/id
            urlhttp://build.clojure.org/releases/url
        /repository
    /repositories
 /project

 Thanks!


 On Dec 7, 2:34 am, Richard Lyman richard.ly...@gmail.com wrote:
 Can you provide the pom you're using?

 By 'build' do you mean AOT?

 -Rich







 On Tue, Dec 6, 2011 at 3:35 PM, Riccardo riccardo.novie...@gmail.com wrote:
  Hello, I am doing my dissertation project with Clojure and I am using
  Maven to build. It works on REPL and it build successfully, but the
  JAR file doesn't work, it says: Java Exception all the time. Any
  suggestion?

  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with 
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en



-- 
Matteo Moci
http://it.linkedin.com/in/matteomoci
http://about.me/matteomoci/bio

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Building Clojure applications w/ Maven

2011-12-07 Thread Stephen Compall
On Wed, 2011-12-07 at 13:41 +0200, Matteo Moci wrote:
 lein pom
 
 maybe setting up a fake simple lein project
 you can watch how the generated pom is different from yours.

Unfortunately, that pom is too fake to be useful as a comparison tool.


-- 
Stephen Compall
^aCollection allSatisfy: [:each|aCondition]: less is better

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Building Clojure applications w/ Maven

2011-12-07 Thread Stuart Sierra
Adding the Main-Class attribute to a JAR manifest is handled, in Maven, by 
the Assembly Plugin.  See here for examples:

http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

-S

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Building Clojure applications w/ Maven

2011-12-07 Thread Riccardo
That Stuart Sierra? I am a fan of you :) and I have bought Practical
Clojure (but not read much yet).
Thanks, I'll try that solution!

On Dec 7, 8:13 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote:
 Adding the Main-Class attribute to a JAR manifest is handled, in Maven, by
 the Assembly Plugin.  See here for examples:

 http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

 -S

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Building Clojure applications w/ Maven

2011-12-07 Thread Alex Ott
Hi

had you seen my article on Clojure/Maven?
(http://alexott.net/en/clojure/ClojureMaven.html)

P.S. and you can look onto following project
(https://github.com/alexott/clojure-examples/tree/master/compojure-simple)
that uses multi-project maven setup

On Tue, Dec 6, 2011 at 11:35 PM, Riccardo riccardo.novie...@gmail.com wrote:
 Hello, I am doing my dissertation project with Clojure and I am using
 Maven to build. It works on REPL and it build successfully, but the
 JAR file doesn't work, it says: Java Exception all the time. Any
 suggestion?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en



-- 
With best wishes,                    Alex Ott
http://alexott.net/
Tiwtter: alexott_en (English), alexott (Russian)
Skype: alex.ott

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Building Clojure applications w/ Maven

2011-12-07 Thread Riccardo
Right I am finally getting closer: the generated jar finally works,
but it still gives a message A java exception has occurred

My code (not really mine...) look like this:
-
(ns com.yourcompany.defpackage
(:gen-class))


(import '(javax.swing JFrame JButton JOptionPane)) ;'
(import '(java.awt.event ActionListener))  ;'

(let [frame (JFrame. Hello Swing)
 button (JButton. Click Me)]
 (.addActionListener button
   (proxy [ActionListener] []
 (actionPerformed [evt]
   (JOptionPane/showMessageDialog  nil,
  (str htmlHello from bClojure/b. Button 
   (.getActionCommand evt)  clicked.)

 (.. frame getContentPane (add button))

 (doto frame
   (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
   .pack
   (.setVisible true)))

print(code sample)

-

The POM file is this:

---
?xml version=1.0 encoding=UTF-8?
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/maven-v4_0_0.xsd;
properties
clojure.version1.2.0/clojure.version
/properties
  modelVersion4.0.0/modelVersion
  groupIdorg.enclojure/groupId
  artifactIdsample/artifactId
  version0.0.1/version
  nameBanking_Clojure/name
  descriptionBanking_Clojure/description
  build
 sourceDirectorysrc/main/clojure/sourceDirectory
 testSourceDirectorysrc/test/clojure/testSourceDirectory
resources
resource
directorysrc/main/clojure/directory
/resource
resource
directorysrc/main/resources/directory
/resource
/resources
testResources
testResource
directorysrc/test/clojure/directory
/testResource
/testResources
plugins
  plugin
groupIdcom.theoryinpractise/groupId
artifactIdclojure-maven-plugin/artifactId
version1.3.2/version
configuration
sourceDirectories
sourceDirectorysrc/main/clojure/sourceDirectory
/sourceDirectories
clojureOptions-Xmx1G/clojureOptions
/configuration
executions
  execution
idcompile-clojure/id
phasecompile/phase
goals
  goalcompile/goal
/goals
  /execution
/executions
  /plugin
  plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-compiler-plugin/artifactId
configuration
  source1.6/source
  target1.6/target
/configuration
  /plugin

   plugin
artifactIdmaven-assembly-plugin/artifactId
version2.2.2/version
configuration
  descriptorRefs
descriptorRefjar-with-dependencies/descriptorRef
  /descriptorRefs
   archive
manifest
  mainClasscom.yourcompany.defpackage/mainClass
/manifest
  /archive
/configuration
executions
  execution
idmake-assembly/id !-- this is used for inheritance
merges --
phasepackage/phase !-- bind to the packaging phase --

goals
  goalsingle/goal
/goals
  /execution
/executions
  /plugin

/plugins
  /build
  repositories
repository
  idcentral/id
  urlhttp://repo1.maven.org/maven2/url
/repository
repository
  idclojure-releases/id
  urlhttp://build.clojure.org/releases/url
/repository
repository
  idincanter/id
  urlhttp://repo.incanter.org/url
/repository
repository
  idclojure-snapshots/id
  urlhttp://build.clojure.org/snapshots/url
/repository
repository
  idclojars/id
  urlhttp://clojars.org/repo//url
/repository
  /repositories
  dependencies
  dependency
groupIdorg.clojure/groupId
artifactIdclojure/artifactId
version${clojure.version}/version
  /dependency
  dependency
groupIdorg.clojure/groupId
artifactIdclojure-contrib/artifactId
version${clojure.version}/version
  /dependency
dependency
  groupIdswank-clojure/groupId
  artifactIdswank-clojure/artifactId
  version1.2.1/version
exclusions
  exclusion
groupIdorg.clojure/groupId
artifactIdclojure/artifactId
  /exclusion
  exclusion
groupIdorg.clojure/groupId
artifactIdclojure-contrib/artifactId
  /exclusion
/exclusions
/dependency
  /dependencies
/project

-

Many thanks to 

Re: Building Clojure applications w/ Maven

2011-12-07 Thread Riccardo
Oh sorry it is fine now: it's just because there is no output to print
with the last script print(code sample) , after deleting it, the
jar is working fine.
Thanks again.

If somebody else will need more information, the steps to compile this
project were:

Easy AOT Compile with NetbeansMaven

1- Install Maven and Enclojure (in my case)

2- Create a new clojure project

3- In sources create a new clojure file like the above, putting
(ns com.yourcompany.defpackage(:gen-class)) ... at the beginning of
the clj file.

4- Add Assembly Plugin in the POM file specifying the package of the
main clojure file, something like this:
...
plugin
artifactIdmaven-assembly-plugin/artifactId
version2.2.2/version
configuration
  descriptorRefs
descriptorRefjar-with-dependencies/descriptorRef
  /descriptorRefs
   archive
manifest
  mainClasscom.yourcompany.defpackage/mainClass
/manifest
  /archive
/configuration
executions
  execution
idmake-assembly/id !-- this is used for inheritance
merges --
phasepackage/phase !-- bind to the packaging phase --

goals
  goalsingle/goal
/goals
  /execution
/executions
  /plugin
...

5- Build the project (with Netbeans just right click on the project)

6- Done



On Dec 8, 12:42 am, Riccardo riccardo.novie...@gmail.com wrote:
 Right I am finally getting closer: the generated jar finally works,
 but it still gives a message A java exception has occurred

 My code (not really mine...) look like this:
 -
 (ns com.yourcompany.defpackage
         (:gen-class))

 (import '(javax.swing JFrame JButton JOptionPane)) ;'
 (import '(java.awt.event ActionListener))          ;'

 (let [frame (JFrame. Hello Swing)
      button (JButton. Click Me)]
  (.addActionListener button
    (proxy [ActionListener] []
      (actionPerformed [evt]
        (JOptionPane/showMessageDialog  nil,
           (str htmlHello from bClojure/b. Button 
                (.getActionCommand evt)  clicked.)

  (.. frame getContentPane (add button))

  (doto frame
    (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
    .pack
    (.setVisible true)))

 print(code sample)

 -

 The POM file is this:

 ---
 ?xml version=1.0 encoding=UTF-8?
 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.0http://maven.apache.org/maven-v4_0_0.xsd;
 properties
         clojure.version1.2.0/clojure.version
 /properties
   modelVersion4.0.0/modelVersion
   groupIdorg.enclojure/groupId
   artifactIdsample/artifactId
   version0.0.1/version
   nameBanking_Clojure/name
   descriptionBanking_Clojure/description
   build
      sourceDirectorysrc/main/clojure/sourceDirectory
      testSourceDirectorysrc/test/clojure/testSourceDirectory
         resources
             resource
                 directorysrc/main/clojure/directory
             /resource
             resource
                 directorysrc/main/resources/directory
             /resource
         /resources
         testResources
             testResource
                 directorysrc/test/clojure/directory
             /testResource
         /testResources
     plugins
       plugin
         groupIdcom.theoryinpractise/groupId
         artifactIdclojure-maven-plugin/artifactId
         version1.3.2/version
         configuration
             sourceDirectories
                 sourceDirectorysrc/main/clojure/sourceDirectory
             /sourceDirectories
             clojureOptions-Xmx1G/clojureOptions
         /configuration
         executions
           execution
             idcompile-clojure/id
             phasecompile/phase
             goals
               goalcompile/goal
             /goals
           /execution
         /executions
       /plugin
       plugin
         groupIdorg.apache.maven.plugins/groupId
         artifactIdmaven-compiler-plugin/artifactId
         configuration
           source1.6/source
           target1.6/target
         /configuration
       /plugin

        plugin
         artifactIdmaven-assembly-plugin/artifactId
         version2.2.2/version
         configuration
           descriptorRefs
             descriptorRefjar-with-dependencies/descriptorRef
           /descriptorRefs
            archive
             manifest
               mainClasscom.yourcompany.defpackage/mainClass
             /manifest
           /archive
         /configuration
         executions
           execution
             idmake-assembly/id !-- this is used for inheritance
 

Building Clojure applications w/ Maven

2011-12-06 Thread Riccardo
Hello, I am doing my dissertation project with Clojure and I am using
Maven to build. It works on REPL and it build successfully, but the
JAR file doesn't work, it says: Java Exception all the time. Any
suggestion?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Building Clojure applications w/ Maven

2011-12-06 Thread Richard Lyman
Can you provide the pom you're using?

By 'build' do you mean AOT?

-Rich



On Tue, Dec 6, 2011 at 3:35 PM, Riccardo riccardo.novie...@gmail.com wrote:
 Hello, I am doing my dissertation project with Clojure and I am using
 Maven to build. It works on REPL and it build successfully, but the
 JAR file doesn't work, it says: Java Exception all the time. Any
 suggestion?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en