maven编译scala,依赖包打包到jar里


<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.0modelVersion>

    <groupId>hahagroupId>
    <artifactId>testartifactId>
    <version>1.0-SNAPSHOTversion>

    <dependencies>
        <dependency> 
            <groupId>org.apache.sparkgroupId>
            <artifactId>spark-sql_2.11artifactId>
            <version>2.2.0version>
        dependency>
        
        <dependency>
            <groupId>org.apache.sparkgroupId>
            <artifactId>spark-mllib_2.11artifactId>
            <version>2.2.0version>
        dependency>

        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>5.1.34version>
        dependency>
        <dependency>
            <groupId>testgroupId>
            <artifactId>test-departifactId>
            <version>1.0-SNAPSHOTversion>
        dependency>
    dependencies>
    <build>
        <plugins>
            
            <plugin>
                <groupId>net.alchim31.mavengroupId>
                <artifactId>scala-maven-pluginartifactId>
                <version>3.1.0version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compilegoal>
                            <goal>testCompilegoal>
                        goals>
                    execution>
                executions>
            plugin>

            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-shade-pluginartifactId>
                <version>2.4.3version>
                <configuration>
                    <shadedArtifactAttached>falseshadedArtifactAttached>
                    <outputFile>${project.build.directory}/shaded/examples-${project.version}-shaded.jaroutputFile>
                    <artifactSet>
                        <includes>
                           
                            <include>groupId:artifactIdinclude>
                        includes>
                    artifactSet>
                configuration>
                <executions>
                    <execution>
                        <phase>packagephase>
                        <goals>
                            <goal>shadegoal>
                        goals>
                    execution>
                executions>
            plugin>
        plugins>
    build>
project>
<build>
     <plugins>
         <plugin>
             <artifactId>maven-assembly-pluginartifactId>
             <version>3.1.0version>
             <configuration>
                 <descriptorRefs>
                     <descriptorRef>jar-with-dependenciesdescriptorRef>
                 descriptorRefs>
                 <appendAssemblyId>falseappendAssemblyId> 
             configuration>
             <executions>
                 <execution>
                     <id>make-assemblyid> 
                     <phase>packagephase> 
                     <goals>
                         <goal>singlegoal>
                     goals>
                 execution>
             executions>
         plugin>
         <plugin>
             <groupId>org.apache.maven.pluginsgroupId>
             <artifactId>maven-compiler-pluginartifactId>
             <configuration>
                 <source>1.8source>
                 <target>1.8target>
             configuration>
         plugin>
     plugins>
 build>

你可能感兴趣的:(maven)