小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

How to: installers, Jetty, postgresql with maven2

 figol 2006-12-12
I had the following requirements:
  1. create an installer for my application;
  2. the application is based on web-technologies, so the installer must ship an application server and automatically install my webapp into it;
  3. the application requires a dbms (Postgres was the choice, a similar process will work also with Hsqldb), so the installer must ship it, possibly automatically installing it on the target machine;
  4. my application is build through maven, so the creation of the installer should be integrated in the whole build chain;
  5. the installer must be easy to use, even for monkey-brained users

I looked for a standardized way to do all this: although Maven team has planned some native support for this kind of problems see this, at the moment there are only partial solutions from non-mainstream external plugins. I‘ll go through the entire process, and at the end, some more alternatives are proposed.
The solution I ended up involves the following steps:
  1. install Postgres installer into a maven repository: this is an easy step, because it only requires to zip the target file (i did it manually, but if you really you can let maven do it for you...which I don‘t suggest at all), and install and deploy it into your local repository. So I downloaded the file from the msi postgres windows and issued this:
    mvn  -Dfile=postgres-installer.zip \n 
    -DgeneratePom=true \n
    -DgroupId=postgres \n
    -DartifactId=postgres-installer \n
    -Dversion=VERSION-NUMBER -DrepositoryId=SERVER \n
    -Durl=scp://path/to/your/maven2/repository \n
    -Dpackaging=zip \n
    deploy:deploy-file
  2. install an application server into a maven repository: do the same for your application server of choice: mine was jetty, because I use it heavily during development, and because its installint procedure is a matter of unzipping and copying its files somewhere (which other application servers allow this ?):
    mvn  -Dfile=jetty-6.0.2.zip \n 
    -DgeneratePom=true \n
    -DgroupId=jetty \n
    -DartifactId=jetty \n
    -Dversion=VERSION-NUMBER -DrepositoryId=SERVER \n
    -Durl=scp://path/to/your/maven2/repository \n
    -Dpackaging=zip \n
    deploy:deploy-file
  3. install the application war into a maven repository: this is maybe the easiest step: given your webapp, which should have a packaging element of value war, it is only a matter of doing a mvn deploy from the root of your project, given that you‘ve provided the correct distribution management informations in the pom; i won‘t comment further on this;
  4. install locally the izpack-maven-plugin: this mojo is still a proposal, so you can‘t simply declare it in your pom: you need to install by your self. Let‘s get it from Jira and from the root directory:
    mvn install
  5. use the maven-dependency-plugin properly:this is the interesting part. It requires just a little bit of knowledge of the goals available through this plugin and to combine them propertly. here is the result:
    <plugins>
    <plugin>
    <groupId>org.codehaus.mojo</groupId>

    <artifactId>dependency-maven-plugin</artifactId>
    <executions>
    <!-- unzip jetty & postgresql -->
    <execution>
    <id>unzip-jetty-postgresql</id>

    <phase>process-resources</phase>
    <goals>
    <goal>unpack</goal>
    </goals>
    <configuration>

    <artifactItems>
    <artifactItem>
    <groupId>jetty</groupId>
    <artifactId>jetty-standalone</artifactId>
    <version>6.0.2</version>

    <type>zip</type>
    <outputDirectory>
    ${project.build.directory}/${project.build.finalName}/
    </outputDirectory>
    </artifactItem>
    <artifactItem>

    <groupId>postgresql</groupId>
    <artifactId>postgresql-installer-win</artifactId>
    <version>8.1.5</version>
    <type>zip</type>

    <outputDirectory>
    ${project.build.directory}/${project.build.finalName}/postgresql/
    </outputDirectory>
    </artifactItem>
    </artifactItems>
    </configuration>
    </execution>

    <execution>
    <id>copy-webapp-war</id>
    <phase>process-resources</phase>
    <goals>

    <goal>copy</goal>
    </goals>
    <configuration>
    <stripVersion>true</stripVersion>
    <artifactItems>

    <artifactItem>
    <groupId>your-groupid</groupId>
    <artifactId>your-webapp</artifactId>
    <version>1.0-SNAPSHOT</version>

    <type>war</type>
    <outputDirectory>
    ${project.build.directory}/${project.build.finalName}/jetty-6.0.2/webapps/
    </outputDirectory>
    </artifactItem>

    </artifactItems>
    </configuration>
    </execution>
    </executions>
    </plugin>

    </plugins>
  6. configure the izpack plugin to run in the package phase: this is very easy, and goes like this:
    <plugin>

    <groupId>org.codehaus.mojo</groupId>
    <artifactId>izpack-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <executions>

    <execution>
    <phase>package</phase>
    <goals>
    <goal>izpack</goal>
    </goals>

    </execution>
    </executions>
    </plugin>

Having this pom configuration, it is enough to issue mvn package to find in our target/ directory a beautiful executable jar file, which will install our application, togheter with postgres and application in the target machine.
Ah, sure: you need a working izpack.xml file in src/izpack/ directory to let the maven plugin works correctly. In a future blog entry, I‘ll go on with this example showing how to write such file.
One more thing: very recently, Vincent Massol proposed a new support (the Packager API) within the core api of cargo plugin, which should greetly simplify this process. Stay tuned!

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多