Giter Club home page Giter Club logo

Comments (3)

chrisdchristo avatar chrisdchristo commented on June 11, 2024

Hi, thanks for reporting. Apologies if it wasn't a completely smooth process to get you setup! I've adjusted to the readme in light of your concerns.

I'm not sure you can automatically bind a phase to a plugin? You can set a default phase (and thus not requiring the <phase> tag in the execution) but thats about it.

So what you can do is:

<plugin>
    <groupId>com.github.chrischristo</groupId>
    <artifactId>capsule-maven-plugin</artifactId>
    <version>${capsule.maven.plugin.version}</version>
    <configuration>
        <appClass>hello.HelloWorld</appClass>
    </configuration>
</plugin>

but make sure you include the package command as you know: mvn package capsule:build

or define with an execution (the default phase is package so you don't need to specify):

<plugin>
    <groupId>com.github.chrischristo</groupId>
    <artifactId>capsule-maven-plugin</artifactId>
    <version>${capsule.maven.plugin.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>build</goal>
            </goals>
            <configuration>
                <appClass>hello.HelloWorld</appClass>
            </configuration>
        </execution>
    </executions>
</plugin>

Also, for certain scenarios the second option where you hook the plugin in the package phase is not desirable. For example you might be using the exec plugin where you run the app directly. This requires you to build the package phase, something like mvn package exec:java. However to execute this command you do not need the capsule built jars, thus this would add pointless build time when you just want to run your app (Think about large apps too). This is actually how I develop, I use the exec plugin to run my app quickly, but when I want to release, I build the artifact into a capsule to deploy to a server.

from capsule-maven-plugin.

StanAccy avatar StanAccy commented on June 11, 2024

Thanks Chris (for the answer and for writing the plugin - it works great). Our initial forays were successful - it was only when we went to build the capsule manually that we noticed this problem. There must be a way to auto-bind to the package phase (perhaps my terminology is off here with phase/execution binding) since all the "standard" plugins do so - JAR, WAR etc. Impact on build time for us is pretty irrelevant - while our total package size is upwards of 60Mb, the time it takes to assemble is barely noticeable.

As for your use case of running the app - I hadn't thought of that (since java -jar ourjar-fat.jar is already super simple). You might want to bump that idea up the docs a little since it makes things super easy. If its there already, I totally missed it, but its a great use case for testing and dev.

Thanks again

from capsule-maven-plugin.

chrisdchristo avatar chrisdchristo commented on June 11, 2024

I think what you desire is a custom packaging type for maven. Something like <packaging>capsule</packaging> instead of <packaging>jar</packaging>. This is quite a difficult thing to implement as you would need to add custom configurations to a maven install as shown here. Also, the original jar still needs to be built (so it can be included in the capsule) so this new packaging type would have to accommodate the preceding step. A custom packaging type is not something I've implemented before so forgive me if any of the above is incorrect.

Honestly, I think its fine as is. Include the plugin with the execution step for your needs (so the capsule is built automatically at the package phase):

<plugin>
    <groupId>com.github.chrischristo</groupId>
    <artifactId>capsule-maven-plugin</artifactId>
    <version>${capsule.maven.plugin.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>build</goal>
            </goals>
            <configuration>
                <appClass>hello.HelloWorld</appClass>
            </configuration>
        </execution>
    </executions>
</plugin>

And yeah, for the use case I described before, all you need is the one step of mvn package exec:java which is even simpler than running the two step mvn package capsule:build && java -jar target/ourjar-fat.jar ;).

I'll bump that up in the readme to hopefully encourage others. Thanks :).

from capsule-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.