스칼라 코드를 사용하는 Maven 프로젝트를 가지고 있고 다른 스칼라 버전 (2.10.6 및 2.11.8)을 기반으로 두 개의 jar 파일을 생성하려고합니다. 만약 누군가가 단일 maven 설치 실행에서 이것을 달성 할 수있는 방법을 제안하거나 Maven 플러그 인을 사용하여이를 Maven에서 구현하는 다른 방법이 있다면다른 스칼라 버전을 사용하여 동일한 Maven 프로젝트의 두 개의 jar 파일 생성
0
A
답변
1
여러 번 실행하여이 문제를 해결할 수 있습니다.
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>scala-version-2.10</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<scalaVersion>2.10.6</scalaVersion>
<outputDir>${project.build.outputDirectory}/scala-2.10</outputDir>
</configuration>
</execution>
<execution>
<id>scala-version-2.11</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<scalaVersion>2.11.8</scalaVersion>
<outputDir>${project.build.outputDirectory}/scala-2.11</outputDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>scala-2.10</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<classifier>scala-2.10</classifier>
<excludes>
<exclude>scala-2.11/**</exclude>
<exclude>sparkScala/**</exclude>
<exclude>sparksql/**</exclude>
<exclude>*.timestamp</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>scala-2.11</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<classifier>scala-2.11</classifier>
<excludes>
<exclude>scala-2.10/**</exclude>
<exclude>sparkScala/**</exclude>
<exclude>sparksql/**</exclude>
<exclude>*.timestamp</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
1
다른 버전의 Scala에 대해 종속성을 갖는 프로파일을 생성하십시오 . 두 프로필 모두에서 mvn install
을 실행해야합니다. 자세한 내용은 다음을 참조하십시오. different-dependencies-for-different-build-profiles-in-maven
또한이 두 가지를 구별하기 위해 프로필의 이슈 이름/버전을 변경해야합니다.