Maven actual reading notes

Section 2.4
some companies based on security considerations, require the use of a proxy to access the Internet through safety certification. For example, now have an IP address is 218.14.227.197, port 3128 for the proxy server, we need to configure Http proxy in settings.xml.

<setting>
    <proxies>
        <proxy>
            <id>my-proxy</id>
            <active>true</active>
            <protocol>http</protocol>
            <host>218.14.227.197</host>
            <port>3128</port>
            <!--
            <username>xxx</username>
            <password>yyy</ password> 
            which does not require a proxy hostname
            <nonProxyHosts>repository.mycom.com|*.google.com</nonProxyHosts>
            -->
        </proxy>
    </proxies>
</setting>
View Code

Section 3.4
is generated by default jar package is not able to run directly, because the META-INF jar file / MANIFEST.MF not configured Main-Class.
To generate executable jar, can be used maven-shade-plugin, as follows:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.MainfestResourceTransformer">
                                <mainClass></mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
View Code

java -jar xxx.jar


Section 7.4.2
will be a plug-target bound to a certain stage of the life cycle.
Create a project source code jar package, maven-source-plugin: jar -no-fork target can be packaged into a jar file the main code, bind it to default on the verify stage life cycle, create source packages before testing finished mounting member .

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jar-no-fork</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
View Code

Section 7.5.3
maven-plugin-antrun: RUN can be used to invoke the Ant task in the maven.
The maven-antrun-plugin: run to bind to multiple stages, plus different configurations, so maven to perform different tasks at different stages.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <id>ant-validate</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <echo>I'm bound to validate phase.</echo>
                        </tasks>
                    </configuration>
                </execution>
                <execution>
                    <id>ant-verify</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <echo>I'm bound to verify phase.</echo>
                        </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
View Code

8.3.3
dependent import range only in dependencyManagement elements have the effect, use is generally dependent on the range of points a pom, pom target function is arranged in dependencyManagement introduced and incorporated into the current dependencyManagement pom configuration.
In addition to inheriting and replication configuration, you can also use this configuration to import range depends introduced.

    < The dependencyManagement > 
        < Dependencies > 
            < dependency > 
                < the groupId > XXX </ the groupId > 
                < the artifactId > yyy </ the artifactId > 
                < Version > 1.0 </ Version > 
                < type > POM </ type > 
                <-! Particularity import range generally packaged point pom module type -> 
                < scope > Import </ scope > 
            </dependency>
        </dependencies>
    </dependencyManagement>

8.3.4
explicitly mentioned in the statement pluginManagement plug-in configuration, the sub-module needs to declare.


Section 12.1
the WAR bag with WEB-INF, there are classes folder under WEB-INF, as well lib folder. and classes at runtime lib directory will be added to the ClassPath.
web project and resource files in the same general class jar projects, the default location is src / main / java, src / main / resources. The place is rather special, web project there is a web resource directory, the default location src / main / webapp. war package has a lib directory, but maven project structure and there is no such a directory because maven dependencies disposed in the pom.


Section 14.5
web project, there are two resource file, resource files, and general web resource files, the former by maven-resources-plugin treatment, the latter through the maven-war-plugin process.
A web resource directory src / main / webapp / open filter:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-beta-1</version>
            <configuration>
                <webResources>
                    <resource>
                        <filtering>true</filtering>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/*.css</include>
                            <include>**/*.js</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
    </plugins>
</build>
View Code

 





























Guess you like

Origin www.cnblogs.com/Mike_Chang/p/12588950.html