java - Intellij思想: from sources to project using Maven

标签 java maven

我从这里下载了一个名为WebGraph的软件包的源代码:http://webgraph.di.unimi.it/webgraph-3.6.1-src.tar.gz ,解压它并从 IntellijIdea 打开它(一路上为项目设置 SDK)。到目前为止,一切都很好。 现在,某些 pom-model.xmlivy.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 函数。我想使用某些命令行参数来运行它。 它位于名为 BreadthFirst.java 的包 it.unimi.dsi.webgraph.examples 中。 我在这里描述的似乎是一个相当通用的场景,因此解决方案可能会让很多人受益。作为 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

编辑:我可能想修改代码,因此将其构建为独立项目对我来说至关重要。

最佳答案

您只是想在您的程序中使用这个库吗?如果是这样,我建议只将依赖项添加到主 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 中。

关于java - Intellij思想: from sources to project using Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48593344/

相关文章:

maven - Nexus 3 支持 Maven 吗?

java - 如果未激活另一个配置文件,则激活 Maven 配置文件

java - 我需要什么 Maven 依赖项才能获取 FileCredentialStore?

java - Maven 依赖项到底是什么?

java - 从显示图像的 Activity 来回移动时,会出现内存错误。不释放图像?

java - 为什么我们可以使用 'new' 关键字来获取非静态外部类中静态内部类的引用?

java - 添加横向 Jpanel

java - 报错Sqoop mysql驱动加载异常

java - list .mf : reference Main-class in jar file

maven - 如何避免 Maven 中出现空测试 JAR?