2016-11-08 17 views
1

我创建了一个P2回购补充一点,我后来成为第谷的依赖使用插件。然而我偶然发现了lombok依赖的错误堆栈。我知道龙目岛有点特别的依赖。所以我下载它并将其添加到我的插件文件夹并安装它。我得到一个不同的错误比我根本就没有在plugins文件夹中的文件夹lombok.jar但在错误堆栈中所列的建议,并没有解决问题。我也试过在这个计算器等岗位Maven的第谷说龙目岛所需的神器缺少虽然其他依赖工作

mvn package fails with Required Artifact Missing even though it exists in my Remote Repository

讨论解决方案,但我仍然有同样的错误。我的groovy依赖添加没有问题。

``` mvn eclipse:eclipse 
[INFO] Scanning for projects... 
[INFO] Computing target platform for MavenProject: com.project:com.project.bbcode.parser:1.0.0-SNAPSHOT @ C:\Users\Khady\temp\bbcode-lite-parser\pom.xml 
[WARNING] Missing POM for org.projectlombok:com.project.lombok:jar:1.16.8 
[ERROR] Internal error: java.lang.RuntimeException: Could not resolve project dependencies: Missing: 
[ERROR] ---------- 
[ERROR] 1) org.projectlombok:com.project.lombok:jar:1.16.8 
[ERROR] 
[ERROR] Try downloading the file manually from the project website. 
[ERROR] 
[ERROR] Then, install it using the command: 
[ERROR] mvn install:install-file -DgroupId=org.projectlombok -DartifactId=com.project.lombok -Dversion=1.16.8 -Dpackaging=jar -Dfile=/path/to/file 
[ERROR] 
[ERROR] Alternatively, if you host your own repository you can deploy the file there: 
[ERROR] mvn deploy:deploy-file -DgroupId=org.projectlombok -DartifactId=com.project.lombok -Dversion=1.16.8 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] 
[ERROR] 
[ERROR] Path to dependency: 
[ERROR] 1) com.project:com.project.bbcode.parser:pom:1.0.0-SNAPSHOT 
[ERROR] 2) org.projectlombok:com.project.lombok:jar:1.16.8 
[ERROR] 
[ERROR] ---------- 
[ERROR] 1 required artifact is missing. 
[ERROR] 
[ERROR] for artifact: 
[ERROR] com.project:com.project.bbcode.parser:pom:1.0.0-SNAPSHOT 
[ERROR] 
[ERROR] from the specified remote repositories: 
[ERROR] project-plugins (file:C:/Users/Khady/temp/repository, releases=false, snapshots=false), 
[ERROR] eclipse-luna (http://download.eclipse.org/releases/luna, releases=false, snapshots=false), 
[ERROR] central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false), 
[ERROR] projectlombok.org (http://projectlombok.org/mavenrepo, releases=true, snapshots=true) 
[ERROR] -> [Help 1] 
org.apache.maven.InternalErrorException: Internal error:  java.lang.RuntimeException: Could not resolve project dependencies 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:121) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: java.lang.RuntimeException: Could not resolve project dependencies 
    at org.eclipse.tycho.p2.resolver.P2DependencyResolver.collectPomDependencies(P2DependencyResolver.java:276) 
    at org.eclipse.tycho.p2.resolver.P2DependencyResolver.computePreliminaryTargetPlatform(P2DependencyResolver.java:204) 
    at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject(DefaultTychoResolver.java:109) 
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:95) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:266) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) 
    ... 11 more 
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing: 
---------- 
1) org.projectlombok:com.project.lombok:jar:1.16.8 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=org.projectlombok - DartifactId=com.project.lombok -Dversion=1.16.8 -Dpackaging=jar -Dfile=/path/to/file 

    Alternatively, if you host your own repository you can deploy the file there: 
     mvn deploy:deploy-file -DgroupId=org.projectlombok -DartifactId=com.project.lombok -Dversion=1.16.8 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] 

    Path to dependency: 
     1) com.project:com.project.bbcode.parser:pom:1.0.0-SNAPSHOT 
     2) org.projectlombok:com.project.lombok:jar:1.16.8 

---------- 
1 required artifact is missing. 

for artifact: 
    com.project:com.project.bbcode.parser:pom:1.0.0-SNAPSHOT 

    from the specified remote repositories: 
    project-plugins (file:C:/Users/Khady/temp/repository, releases=false,  snapshots=false), 
    eclipse-luna (http://download.eclipse.org/releases/luna, releases=false, snapshots=false), 
     central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false), 
    projectlombok.org (http://projectlombok.org/mavenrepo, releases=true, snapshots=true) 

     at org.apache.maven.artifact.resolver.DefaultResolutionErrorHandler.throwErrors(DefaultResolutionErrorHandler.java:71) 
     at org.apache.maven.DefaultProjectDependenciesResolver.resolveImpl(DefaultProjectDependenciesResolver.java:164) 
     at org.apache.maven.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:76) 
     at org.apache.maven.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:60) 
     at org.eclipse.tycho.p2.resolver.P2DependencyResolver.collectPomDependencies(P2DependencyResolver.java:263) 
    ... 17 more 
[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/InternalErrorException 

```

我的POM文件(有一个父POM的方式)

``` <?xml version="1.0" encoding="UTF-8"?> 

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.project</groupId> 
    <artifactId>com.project.bbcode.parser</artifactId> 
    <version>1.0.0-SNAPSHOT</version> 
    <packaging>eclipse-plugin</packaging> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <tycho-version>0.26.0</tycho-version> 
    </properties> 

    <repositories> 
     <repository> 
      <id>project-plugins</id> 
      <url>file:C:/Users/Khady/temp/repository</url> 
      <layout>p2</layout> 
     </repository> 
     <repository> 
      <id>eclipse-luna</id> 
      <layout>p2</layout> 
      <url>http://download.eclipse.org/releases/luna</url> 
     </repository> 
     <repository> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
      <id>central</id> 
      <name>Central Repository</name> 
      <url>https://repo.maven.apache.org/maven2</url> 
     </repository> 
     <repository> 
     <id>projectlombok.org</id> 
     <url>http://projectlombok.org/mavenrepo</url> 
    </repository> 
    </repositories> 

    <build> 
     <sourceDirectory>src/main/java</sourceDirectory> 
     <testSourceDirectory>test/main/groovy</testSourceDirectory> 
     <resources> 
      <resource> 
      <directory>src/main/java</directory> 
       <includes> 
       <include>**/*.groovy</include> 
      </includes> 
      </resource> 
     </resources> 
     <testResources> 
      <testResource> 
      <directory>test/main/groovy</directory> 
      <includes> 
       <include>**/*.groovy</include> 
      </includes> 
      <excludes> 
       <exclude>**/*.java</exclude> 
      </excludes> 
      </testResource> 
     </testResources> 
     <plugins> 
      <plugin> <!-- enable the Tycho build extension --> 
       <groupId>org.eclipse.tycho</groupId> 
       <artifactId>tycho-maven-plugin</artifactId> 
       <version>0.26.0</version> 
       <extensions>true</extensions> 
      </plugin> 
      <plugin> <!-- To compile java code --> 
       <groupId>org.eclipse.tycho</groupId> 
       <artifactId>tycho-compiler-plugin</artifactId> 
       <version>0.26.0</version> 
       <configuration> 
        <compilerArgs> 
        <arg>-warn:-raw,unchecked</arg> 
        </compilerArgs> 
       </configuration> 
      </plugin> 
      <plugin> <!-- To run tests --> 
       <groupId>org.eclipse.tycho</groupId> 
       <artifactId>tycho-surefire-plugin</artifactId> 
       <version>0.26.0</version> 
       <configuration> <!-- for UI test --> 
       <useUIHarness>true</useUIHarness> 
       </configuration>   
      </plugin> 
      <plugin> 
       <groupId>org.eclipse.tycho.extras</groupId> 
       <artifactId>tycho-p2-extras-plugin</artifactId> 
       <version>${tycho-version}</version> 
       <executions> 
        <execution> 
         <phase>prepare-package</phase> 
         <goals> 
          <goal>publish-features-and-bundles</goal> 
         </goals> 
         <configuration> 
          <compress>false</compress> 
          <artifactRepositoryLocation>/C:/Users/Khady/temp/repository</artifactRepositoryLocation> 
          <metadataRepositoryLocation>/mypath/target/repository</metadataRepositoryLocation> 
          <sourceLocation>/C:/Users/Khady/temp/plugins</sourceLocation> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.eclipse.tycho</groupId> 
       <artifactId>tycho-p2-repository-plugin</artifactId> 
       <version>${tycho-version}</version> 
       <configuration> 
       </configuration> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>verify-repository</goal> 
          <goal>archive-repository</goal> 
         </goals> 
         <configuration> 
          <compress>true</compress> 
          <includeAllDependencies>true</includeAllDependencies> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.eclipse.tycho</groupId> 
       <artifactId>tycho-p2-publisher-plugin</artifactId> 
       <version>${tycho-version}</version> 
       <configuration> 
        <publishArtifacts>true</publishArtifacts> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.eclipse.tycho</groupId> 
       <artifactId>target-platform-configuration</artifactId> 
       <version>${tycho-version}</version> 
       <configuration> 
       <resolver>p2</resolver> 
       <pomDependencies>consider</pomDependencies> 
       <ignoreTychoRepositories>true</ignoreTychoRepositories> 
        <environments> 
        <environment> 
         <os>win32</os> 
         <ws>win32</ws> 
         <arch>x86</arch> 
        </environment> 
        <environment> 
         <os>linux</os> 
         <ws>gtk</ws> 
         <arch>x86_64</arch> 
        </environment> 
        <environment> 
         <os>macosx</os> 
         <ws>cocoa</ws> 
         <arch>x86_64</arch> 
        </environment> 
        </environments> 
       </configuration> 
      </plugin> 
     </plugins> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.1</version> 
        <configuration> 
         <compilerId>groovy-eclipse-compiler</compilerId> 
         <verbose>true</verbose> 
         <fork>true</fork> 
         <compilerArguments> 
         <javaAgentClass>lombok.launch.Agent</javaAgentClass> 
         </compilerArguments> 
        </configuration> 
        <dependencies> 
         <dependency> 
          <groupId>org.codehaus.groovy</groupId> 
          <artifactId>groovy-eclipse-compiler</artifactId> 
          <version>2.9.1-01</version> 
         </dependency> 
         <!-- for 2.8.0-01 and later you must have an explicit dependency on groovy-eclipse-batch --> 
         <dependency> 
          <groupId>org.codehaus.groovy</groupId> 
          <artifactId>groovy-eclipse-batch</artifactId> 
          <version>2.3.7-01</version> 
         </dependency> 
         <dependency> 
          <groupId>org.projectlombok</groupId> 
          <artifactId>lombok</artifactId> 
          <version>1.16.8</version> 
         </dependency> 
        </dependencies> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 

    <!-- DEPENDENCIES --> 
    <dependencies> 
     <dependency> 
      <groupId>org.codehaus.groovy</groupId> 
      <artifactId>groovy-all</artifactId> 
      <version>2.4.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.projectlombok</groupId> 
      <artifactId>lombok</artifactId> 
      <version>1.16.8</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.14.1</version> 
      <type>maven-plugin</type> 
     </dependency> 
    </dependencies> 

</project> 

```

+0

的URL'HTTP:// projectlombok.org/mavenrepo'似乎是,尽管它的名字没有Maven仓库... – khmarbaise

+0

确定我会尝试找出正确的网址 – kloklo90

回答

0

龙目岛不同的行为有点作为一个依赖。有两种方法可以让你的lombok相关代码工作。

您可以添加龙目岛作为一个依赖,如下图所示,然后用MVN安装到让它每次你做一个干净的MVN按时上班。另外,您可以打的Maven - >更新项目...发现,如果你右击每次你做一个干净的MVN时间在Eclipse项目。它应该让Lombok重新加载回来。

<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok-maven --> 
<dependency> 
<groupId>org.projectlombok</groupId> 
<artifactId>lombok-maven</artifactId> 
<version>1.16.8.0</version> 
</dependency> 

我发现这一切cubbersome的,所以我看着这并不需要右键点击或每MVN干净后MVN安装的替代解决方案。我用delombok一个强大的工具来龙目岛代码转换为东西你的Maven第谷的编译器可以消化。 http://awhitford.github.io/lombok.maven/lombok-maven-plugin/delombok-mojo.html。只需将其添加到您的pom中,并将源文件夹的名称更改为src/main/lombok。当运行时,它会创建/更新的src/main/java文件夹与所有在它delomboked代码不要担心。所以Maven仍将使用src/main/java作为源文件夹来编译所有代码。

<!--LOMBOK SCHBANG--> 
     <plugin> 
      <groupId>org.projectlombok</groupId> 
      <artifactId>lombok-maven-plugin</artifactId> 
      <version>1.16.8.0</version> 
      <executions> 
       <execution> 
       <id>delombok</id> 
       <phase>generate-sources</phase> 
       <goals> 
        <goal>delombok</goal> 
       </goals> 
       </execution> 
       <execution> 
       <id>test-delombok</id> 
       <phase>generate-test-sources</phase> 
       <goals> 
        <goal>testDelombok</goal> 
       </goals> 
       <configuration> 
        <addOutputDirectory>false</addOutputDirectory> 
        <sourceDirectory>src/test/java</sourceDirectory> 
       </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <!--To copy delomboked classes back into src folder--> 
     <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-resources-plugin</artifactId> 
    <version>2.3</version> 
    <executions> 
     <execution> 
      <id>copy-prod-resources</id> 
      <phase>process-resources</phase> 
      <goals> 
       <goal>copy-resources</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>src/main/java</outputDirectory> 
       <resources> 
        <resource> 
         <directory>target/generated-sources/delombok</directory> 
         <filtering>false</filtering> 
        </resource> 
       </resources> 
      </configuration> 
     </execution> 
    </executions> 
</plugin>