我从这里下载了一个名为WebGraph的软件包的源代码:http://webgraph.di.unimi.it/webgraph-3.6.1-src.tar.gz,将其解压缩并从IntellijIdea打开它(为此项目设置SDK)。到现在为止还挺好。
现在,某些pom-model.xml
和ivy.xml
文件包含以下内容:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.unimi.dsi</groupId>
<artifactId>${ivy.pom.artifactId}</artifactId>
<packaging>jar</packaging>
<name>WebGraph</name>
<version>${ivy.pom.version}</version>
<description>WebGraph is a framework to study the web graph. It provides simple ways to manage very large graph, exploiting modern compression techniques.</description>
<url>http://webgraph.dsi.unimi.it/</url>
<licenses>
<license>
<name>GNU General Public License Version 3+</name>
<url>http://www.gnu.org/licenses/gpl.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git://github.com/vigna/WebGraph.git</connection>
<url>https://github.com/vigna/WebGraph</url>
</scm>
<developers>
<developer>
<id>boldi</id>
<name>Paolo Boldi</name>
<email>boldi@dsi.unimi.it</email>
</developer>
<developer>
<id>vigna</id>
<name>Sebastiano Vigna</name>
<email>vigna@dsi.unimi.it</email>
</developer>
</developers>
</project>
和
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="it.unimi.dsi" module="webgraph"/>
<configurations defaultconf="compile" defaultconfmapping="*->default">
<conf name="compile"/>
<conf name="runtime" extends="compile"/>
<conf name="test" extends="runtime"/>
</configurations>
<dependencies>
<dependency org="it.unimi.dsi" name="fastutil" rev="latest.release" />
<dependency org="it.unimi.dsi" name="sux4j" rev="latest.release" />
<dependency org="it.unimi.dsi" name="dsiutils" rev="latest.release" />
<dependency org="net.sf.jung" name="jung-api" rev="latest.release"/>
<dependency org="net.sf.jung" name="jung-io" rev="latest.release"/>
<dependency org="com.martiansoftware" name="jsap" rev="latest.release"/>
<dependency org="junit" name="junit" rev="latest.release" conf="test"/>
<dependency org="emma" name="emma" rev="latest.release" conf="test"/>
<dependency org="emma" name="emma_ant" rev="latest.release" conf="test"/>
<dependency org="ch.qos.logback" name="logback-classic" rev="latest.release" conf="runtime"/>
<dependency org="commons-configuration" name="commons-configuration" rev="latest.release"/>
<dependency org="org.apache.commons" name="commons-lang3" rev="latest.release"/>
</dependencies>
</ivy-module>
此程序包所需的其他库可在此处找到:http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22it.unimi.dsi%22
现在,此包中有一个示例类,它包含main
函数。我想用某些命令行参数运行它。
它位于名为it.unimi.dsi.webgraph.examples
的包BreadthFirst.java
中。
我在这里描述的似乎是一个相当普遍的场景,因此解决方案可能会使许多人受益。作为Maven和Java基础设施的新手,我很乐意了解下一步我需要做什么。在这种情况下我应该寻找什么?至于现在,当我尝试运行项目时,输出是:
/usr/lib/jvm/jdk1.8.144/bin/java -Dmaven.multiModuleProjectDirectory=/home/sj/Downloads/webgraph-3.6.1 -Dmaven.home=/usr/local/idea-IC-173.4548.28/plugins/maven/lib/maven3 -Dclassworlds.conf=/usr/local/idea-IC-173.4548.28/plugins/maven/lib/maven3/bin/m2.conf -Didea.launcher.port=37307 -Didea.launcher.bin.path=/usr/local/idea-IC-173.4548.28/bin -Dfile.encoding=UTF-8 -classpath /usr/local/idea-IC-173.4548.28/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar:/usr/local/idea-IC-173.4548.28/lib/idea_rt.jar com.intellij.rt.execution.application.AppMainV2 org.codehaus.classworlds.Launcher -Didea.version=2017.3.4
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'artifactId' contains an expression but should be a constant. @ line 4, column 15
[WARNING] 'version' contains an expression but should be a constant. @ line 7, column 12
[ERROR] 'artifactId' with value '${ivy.pom.artifactId}' does not match a valid id pattern. @ line 4, column 15
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project it.unimi.dsi:${ivy.pom.artifactId}:${ivy.pom.version} (/home/sj/Downloads/webgraph-3.6.1/pom.xml) has 1 error
[ERROR] 'artifactId' with value '${ivy.pom.artifactId}' does not match a valid id pattern. @ line 4, column 15
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
编辑:我可能想要修改代码,因此将其构建为独立项目对我来说至关重要。
答案 0 :(得分:0)
您是否只是想在程序中使用此库?如果是这样,我建议只将依赖项添加到主pom.xml文件中。以下是版本3.6.1的依赖项:
<!-- https://mvnrepository.com/artifact/it.unimi.dsi/webgraph -->
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>webgraph</artifactId>
<version>3.6.1</version>
<scope>runtime</scope>
</dependency>
它有许多“编译依赖项”,如maven repository webpage所列,所以一定要将每个依赖项添加到你的pom中。