tags:

views:

53

answers:

6

Hi,

I think my question is easy. However it is surprising I couldn't find any easy solution.

I'm developing an open source Java library project on Netbeans and like many others I want to release it as binary.jar, source.jar and javadoc.jar.

Is there a way to generate them automatically on Netbeans? I know maven can do it. But the learning curve seems too long.

There is a similar question but the only answer didn't work: http://stackoverflow.com/questions/855498/automatically-generating-source-and-doc-jars-in-netbeans

+2  A: 

Try ant http://ant.apache.org/ . It's easier to learn than maven and can do your code compilation.

kasten
Easier to learn than maven? I seriously doubt that. Yes, it's more powerful than maven, but that's what makes it hard, not easy.
seanizer
In my experience it's the other way around. We used a ant build script to build our application with sourcecode and several jar-files. Later we switched to maven and my impression was that it's more powerful with it's automatic lib fetching. But i have only limited experience with both.
kasten
@seanizer: there's different kinds of hard. Ant is much easier to use and learn incrementally because you don't have to organize your project around it.
Michael Borgwardt
@Michael that's exactly what makes ant hard. With maven, you have to make the transition once and you're up and running, with ant you have to keep tweaking and keep wondering why things don't work like you expect them to. With maven, all plugins act together in a natural way, because there is a well-defined model underneath that everybody uses.
seanizer
@kasten the two key features of maven are a) automated dependency management and b) convention over configuration (e.g. you can rely on the fact that things are where they are supposed to be by querying the appropriate properties). The key feature of ant is that you can do just about anything, but that is also the main bug in my opinion.
seanizer
@seanizer: From what I've heard, some people have made very bad exoeriences with maven acting anything but "natural", wnd while I'm sure it's much easier to get to speed with a large complex maven config than a large complex ant script, if you just want to do X, ant lets you just do that without demanding your right arm, your firstborn and your immortal soul.
Michael Borgwardt
@Michael I guess that depends on your definition of "natural". But I agree with your second point: for small isolated tasks, ant is probably better, maven is better for the big picture. BTW both my right arm and my firstborn son are doing fine, and after recently switching from windows to ubuntu even my immortal soul should be ok.
seanizer
A: 

Maven plugins could be you answer

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.7</version>
    <executions>
        <execution>
            <goals>
                <goal>jar</goal>
            </goals>
            <phase>package</phase>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>2.0.4</version>
    <executions>
        <execution>
            <goals>
                <goal>jar</goal>
            </goals>
            <phase>package</phase>
        </execution>
    </executions>
</plugin>
Paul McKenzie
Just read your question more carefully. However, for a simple project Maven doesn't represent too large a learning curve, imho.
Paul McKenzie
A: 

With ant you can easily generate your javadoc, compile, create jars and zip-file. It's better than do it in netbeans, because if someone want to contribute he could do it with his preferred IDE.

niels
+1  A: 

If you are developing a library that others might help develop then you should think about using Maven.

This way you project will be independent of your IDE and also dependencies, tests and deployment will be taken care of centrally, instead of ever contributor rolling their own.m

Peter Knego
+3  A: 

This is all the maven config you need to attach source and javadoc automatically to the build:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>attach-javadoc</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.1.2</version>
            <executions>
                <execution>
                    <id>attach-source</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

That's not too awful, is it?

seanizer
And people criticize ant for its verbose XML format...
Michael Borgwardt
do they? I only criticize ant because it's awful to code against and to debug. seriously: you could strip groupIds, execution ids and plugin versions from this code and it would be shorter, but I prefer to spell things out.
seanizer