Search code examples
scalaeclipse-pluginsbtexecutable-jarmaven-assembly-plugin

Unable to get external class files of scala in build jar eclipse


I'm trying to create a runnable jar from scala spark project which consumes redis library. So, I created classes from Scala-Redis github project and used the package in my present code. The project builds and runs through eclipse interface but When I try to create jar - I receive classNotfound exception. On checking it was noticed that redis class was not included in build jar. I'm using other external jars as well. They are included in build but not the redis one. Where I'm going wrong or missing ?

Pom.xml is :-

           <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <id>package-jar-with-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <appendAssemblyId>true</appendAssemblyId>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <mainClass>com.spark.ReCalculateOdo</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I've included the class folder in build path run configurations. Suggestions please, Thanks,


Solution

  • I tried one trick and it worked. I don't know why this happens but its working for my case. So the idea is whenever you want a jar just clean build the project then run the project in eclipse now create maven install. You will find a jar in target folder of project. So , now you can use it with command line. It'll work.

    Thanks,