2

I created a p2 repo to add plugins that I later use as tycho dependencies. I however stumble across the error stack below for the lombok dependency. I know lombok is a bit of a special dependency. So I downloaded it and added it to my plugins folder and installed it. I get a different error than when I simply don't have the lombok.jar folder in the plugins folder but the suggestions listed in the error stack did not fix the issue. I also tried solutions discussed in this other stackoverflow post

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

but I still have the same mistake. My groovy dependency was added without problems.

    ``` 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

```

My POM file (there is a parent POM by the way)

``` <?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>

```

Community
  • 1
  • 1
kloklo90
  • 81
  • 1
  • 14

1 Answers1

2

Lombok acts a bit differently as a dependency. There are two ways of getting your lombok dependent code to work.

You can either add lombok as a dependency as shown below, then use mvn install to get it to work each time you do a mvn clean. Alternatively you can hit the Maven -> Update Project... found if you right click on the project in Eclipse every time you do a mvn clean. It should get lombok loaded back in again.

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

I found all of this cubbersome so I looked into an alternative solution that doesn't require right click or mvn install after every mvn clean. I used delombok a powerful tool to convert lombok code to something your maven tycho compiler can digest. http://awhitford.github.io/lombok.maven/lombok-maven-plugin/delombok-mojo.html . Just add this to your pom and change the name of your source folder to src/main/lombok. Don't worry when it runs it will create/update the src/main/java folder with all delomboked code in it. So Maven will still use src/main/java as a source folder to compile all code.

<!--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>
kloklo90
  • 81
  • 1
  • 14