Maven: compiling with all dependencies in one Jar
in pom of a project, i have added dependency with scope compile . which is a jar file which contains some class file and jar's as well. my current java file needs internal jars of dependent jar to compile.
But maven compile goal returning compilation error . :banghead:
All the jar's needed to compile are in the single jar file which is added in dependency.............................
Please help me!
my pom:
<project>
<!-- ... -->
<dependencies>
<dependency>
<groupId>eagle</groupId>
<artifactId>zkui</artifactId>
<version>360LTS</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>./src/main/java</sourceDirectory>
<outputDirectory>./target/classes</outputDirectory>
<finalName>${project.groupId}-${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
error:
package org.zkoss.zk.ui does not exist this package org.zkoss.zk.ui is in j开发者_如何学运维ar file zkex.jar which is in dependency jar eagle:zkui:360LTS jar file
Please Help ME!!!! :jumpingjoy:
Advance Thanks
Well I guess you could
- use
dependency:unpack
to unpack the jars to target/lib or so (before compile) deactivate
compiler:compile
by excluding everything<excludes> <exclude>**/*.java</exclude> </exclude>
use
antrun:run
with the antjavac
task to compile the sources, something like this (bind the execution to phasecompile
):<target> <javac srcdir="${project.build.sourceDirectory}" destdir="${project.build.outputDirectory}"> <classpath> <pathelement path="${maven.compile.classpath}"/> <fileset dir="${project.build.directory}/lib"> <include name="**/*.jar"/> </fileset> </classpath> </javac> </target>
However, while that would help you compile your application, it would not help you run or deploy your application.
You can use the element to do this:
<dependencies>
<dependency>
<groupId>groep.does.not.matter</groupId>
<artifactId>neither-does-artifactId</artifactId>
<version>and.nor-does-version</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${project.baseDir}/lib/jarname.jar</systemPath>
</dependency>
</dependencies>
where the jar you need to reference (and have in your classpath) is lib/jarname.jar, and the lib directory is in the root of your project.
I believe you're actually not using the proper dependencies. ZK actually have Maven repositories as described here.
You need to check which dependencies you need. For example for zkex, you would need something like:
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkex</artifactId>
<version>${zk.version}</version>
</dependency>
You will also need to add the ZK Maven repositories:
<repositories>
<repository>
<id>zk repository</id>
<url>http://mavensync.zkoss.org/maven2</url>
</repository>
<!-- If Using ZK EE or ZK PE Respository (not evaluation version), you need to add login info into ~/.m2/settings.xml -->
<repository>
<id>ZK PE Evaluation</id>
<url>http://mavensync.zkoss.org/zk/pe-eval</url>
</repository>
<repository>
<id>ZK EE Evaluation</id>
<url>http://mavensync.zkoss.org/zk/ee-eval</url>
</repository>
</repositories>
Good luck! :-)
精彩评论