Java 杂谈

maven打包插件:appassembler

2018-12-28  本文已影响5人  AmeeLove

项目

https://www.jianshu.com/p/d8b8bbfc8764

github:https://github.com/ln0491/dubbo-demo

pom.xml

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.ghgcn</groupId>
        <artifactId>dubbo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>dubbo-provider</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.ghgcn</groupId>
            <artifactId>dubbo-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>${dubbo.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.netty</groupId>
                    <artifactId>netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>${version.netty}</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty</artifactId>
            <version>3.10.5.Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>${version.curator}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${version.logback}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>dubbo-provider</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>${version.jdk}</source>
                    <target>${version.jdk}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>



            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>appassembler-maven-plugin</artifactId>
                <version>2.0.0</version>
                <executions>
                    <execution>
                        <id>generate-jsw-scripts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>generate-daemons</goal>
                        </goals>
                        <configuration>

                            <assembleDirectory>${project.build.directory}/dubbo-provider</assembleDirectory>
                            <repositoryName>lib</repositoryName>
                            <!-- 可执行脚本的目录 program可用 -->
                            <binFolder>bin</binFolder>
                            <configurationDirectory>conf</configurationDirectory>
                            <copyConfigurationDirectory>false</copyConfigurationDirectory>
                            <filterConfigurationDirectory>true</filterConfigurationDirectory>
                            <configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
                            <repositoryLayout>flat</repositoryLayout>
                            <encoding>UTF-8</encoding>
                            <logsDirectory>logs</logsDirectory>
                            <useWildcardClassPath>true</useWildcardClassPath>

                            <!-- <platforms> <platform>windows</platform> <platform>unix</platform> 
                                </platforms> -->
                            <!-- <programs> <program> <mainClass>com.ghgcn.benbox.jobcenter.Launcher</mainClass> 
                                <jvmSettings> <extraArguments> <extraArgument>-server</extraArgument> <extraArgument>-Xmx256m</extraArgument> 
                                <extraArgument>-Xms512m</extraArgument> </extraArguments> </jvmSettings> 
                                </program> </programs> -->
                            <daemons>
                                <daemon>
                                    <id>dubbo-provider</id>
                                    <mainClass>com.alibaba.dubbo.container.Main</mainClass>
                                    <platforms>
                                        <platform>jsw</platform>
                                    </platforms>
                                    <generatorConfigurations>
                                        <generatorConfiguration>
                                            <generator>jsw</generator>
                                            <includes>
                                                <include>linux-x86-32</include>
                                                <include>linux-x86-64</include>
                                                <include>windows-x86-32</include>
                                                <include>windows-x86-64</include>
                                            </includes>
                                            <configuration>
                                                <property>
                                                    <name>configuration.directory.in.classpath.first</name>
                                                    <value>conf</value>
                                                </property>
                                                <property>
                                                    <name>wrapper.ping.timeout</name>
                                                    <value>120</value>
                                                </property>
                                                <property>
                                                    <name>set.default.REPO_DIR</name>
                                                    <value>lib</value>
                                                </property>
                                                <property>
                                                    <name>wrapper.ping.interval</name>
                                                    <value>10</value>
                                                </property>
                                                <property>
                                                    <name>wrapper.logfile</name>
                                                    <value>logs/out.log</value>
                                                </property>
                                            </configuration>
                                        </generatorConfiguration>
                                    </generatorConfigurations>
                                    <jvmSettings>
                                        <initialMemorySize>256M</initialMemorySize>
                                        <maxMemorySize>384M</maxMemorySize>
                                        <extraArguments>
                                            <extraArgument>-server</extraArgument>
                                    
                                        </extraArguments>
                                    </jvmSettings>
                                </daemon>
                            </daemons>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

运行命令

clean package -pl dubbo-provider -am -Dmaven.test.skip=true


image.png image.png
image.png

路径

Installing artifact D:\javawork\study\dubbo\dubbo-provider\target\dubbo-provider.jar to D:\javawork\study\dubbo\dubbo-provider\target\generated-resources\appassembler\jsw\dubbo-provider\lib\dubbo-provider-0.0.1-SNAPSHOT.jar

目录:


image.png

lib


image.png
bin 角本
image.png

启动服务

dubbo-provider start
image.png

消息者测试

image.png
image.png

github:https://github.com/ln0491/dubbo-demo

上一篇下一篇

猜你喜欢

热点阅读