使用Tycho使用额外的依赖项时无法编译类

时间:2019-05-19 07:16:31

标签: java eclipse osgi tycho

我的pom:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <configuration>
      <filesets>
        <fileset>
          <directory>${project.basedir}/plugins</directory>
          <includes>
            <include>*.jar</include>
          </includes>
        </fileset>
      </filesets>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
      <execution>
        <id>copy</id>
        <phase>validate</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>commons-lang</groupId>
              <artifactId>commons-lang</artifactId>
              <version>2.6</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-apex</artifactId>
              <version>6.14.0</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-visualforce</artifactId>
              <version>6.14.0</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-core</artifactId>
              <version>6.14.0</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>org.sonarsource.java</groupId>
              <artifactId>sonar-java-plugin</artifactId>
              <version>5.10.2.17019</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>org.sonarsource.javascript</groupId>
              <artifactId>sonar-javascript-plugin</artifactId>
              <version>4.2.1.6529</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>org.sonarsource.php</groupId>
              <artifactId>sonar-php-plugin</artifactId>
              <version>2.16.0.4355</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>org.sonarsource.python</groupId>
              <artifactId>sonar-python-plugin</artifactId>
              <version>1.10.0.2131</version>
              <type>jar</type>
            </artifactItem>
          </artifactItems>
          <outputDirectory>${project.basedir}/plugins</outputDirectory>
          <overWriteReleases>false</overWriteReleases>
          <overWriteSnapshots>true</overWriteSnapshots>
        </configuration>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.xolstice.maven.plugins</groupId>
    <artifactId>protobuf-maven-plugin</artifactId>
    <version>0.5.0</version>
    <configuration>
      <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
      <protoSourceRoot>${project.basedir}/proto</protoSourceRoot>
      <clearOutputDirectory>false</clearOutputDirectory>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
          <goal>test-compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

额外添加的依赖项是:

            <artifactItem>
              <groupId>commons-lang</groupId>
              <artifactId>commons-lang</artifactId>
              <version>2.6</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-apex</artifactId>
              <version>6.14.0</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-visualforce</artifactId>
              <version>6.14.0</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-core</artifactId>
              <version>6.14.0</version>
              <type>jar</type>
            </artifactItem>

我的清单看起来像这样:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundle_name
Bundle-SymbolicName: org.sonarlint.eclipse.core;singleton:=true
Bundle-Version: 4.2.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.sonarlint.eclipse.core.internal.SonarLintCorePlugin
Bundle-Vendor: %bundle_vendor
Bundle-Localization: OSGI-INF/l10n/bundle
Export-Package: org.sonarlint.eclipse.core,
 org.sonarlint.eclipse.core.analysis,
 org.sonarlint.eclipse.core.configurator,
 org.sonarlint.eclipse.core.internal;
  x-friends:="org.sonarlint.eclipse.core.tests,
   org.sonarlint.eclipse.m2e,
   org.sonarlint.eclipse.mylyn.ui,
   org.sonarlint.eclipse.tests.common,
   org.sonarlint.eclipse.ui",
 org.sonarlint.eclipse.core.internal.adapter;x-friends:="org.sonarlint.eclipse.ui",
 org.sonarlint.eclipse.core.internal.event;x-friends:="org.sonarlint.eclipse.ui",
 org.sonarlint.eclipse.core.internal.jobs;x-friends:="org.sonarlint.eclipse.ui,org.sonarlint.eclipse.core.tests,org.sonarlint.eclipse.cdt",
 org.sonarlint.eclipse.core.internal.markers;x-friends:="org.sonarlint.eclipse.ui,org.sonarlint.eclipse.core.tests",
 org.sonarlint.eclipse.core.internal.proto;x-friends:="org.sonarlint.eclipse.core.tests",
 org.sonarlint.eclipse.core.internal.resources;x-friends:="org.sonarlint.eclipse.ui,org.sonarlint.eclipse.core.tests",
 org.sonarlint.eclipse.core.internal.server;x-friends:="org.sonarlint.eclipse.ui,org.sonarlint.eclipse.core.tests",
 org.sonarlint.eclipse.core.internal.telemetry;x-friends:="org.sonarlint.eclipse.ui",
 org.sonarlint.eclipse.core.internal.notifications;x-friends:="org.sonarlint.eclipse.ui,org.sonarlint.eclipse.core.tests",
 org.sonarlint.eclipse.core.internal.tracking;x-friends:="org.sonarlint.eclipse.core.tests",
 org.sonarlint.eclipse.core.internal.utils;x-friends:="org.sonarlint.eclipse.core.tests,org.sonarlint.eclipse.ui",
 org.sonarlint.eclipse.core.resource
Require-Bundle: org.jsr-305;resolution:=optional,
 org.eclipse.core.runtime,
 org.eclipse.core.resources,
 org.eclipse.core.expressions,
 org.eclipse.core.filebuffers,
 org.eclipse.jface.text,
 org.eclipse.core.net,
 org.eclipse.core.filesystem,
 org.eclipse.team.core,
 org.sonarsource.sonarlint.core.sonarlint-client-api;bundle-version="4.0.0",
 org.sonarsource.sonarlint.core.sonarlint-core;bundle-version="4.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

我什至尝试将它们添加到Required Bundle中:

 commons-lang.commons-lang;bundle-version="2.6.0",
 net.sourceforge.pmd.pmd-apex;bundle-version="6.14.0",
 net.sourceforge.pmd-visualforce;bundle-version="6.14.0",
 net.sourceforge.pmd-javascript;bundle-version="6.14.0",
 net.sourceforge.pmd.pmd-core;bundle-version="6.14.0",
 org.eclipse.equinox.security,

错误:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project org.sonarlint.eclipse.core: Compilation failure: Compilation failure:
[ERROR] C:\HCSC\EclipseWorkspace\sonarlint-eclipse-master\sonarlint-eclipse-master\org.sonarlint.eclipse.core\src\org\sonarlint\eclipse\core\internal\ruleSets\ConvertXmlToObjects.java:[22]
[ERROR]         import org.apache.commons.io.IOUtils;
[ERROR]                ^^^^^^^^^^^^^^^^^^
[ERROR] The import org.apache.commons cannot be resolved
[ERROR] C:\HCSC\EclipseWorkspace\sonarlint-eclipse-master\sonarlint-eclipse-master\org.sonarlint.eclipse.core\src\org\sonarlint\eclipse\core\internal\ruleSets\ConvertXmlToObjects.java:[92]
[ERROR]         IOUtils.copy(in, out);
[ERROR]         ^^^^^^^
[ERROR] IOUtils cannot be resolved
[ERROR] C:\HCSC\EclipseWorkspace\sonarlint-eclipse-master\sonarlint-eclipse-master\org.sonarlint.eclipse.core\src\org\sonarlint\eclipse\core\internal\pmd\PmdReviewService.java:[23]
[ERROR]         import net.sourceforge.pmd.*;
[ERROR]                ^^^

还有更多

新错误

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:1.2.0:package-plugin (default-package-plugin) on project org.sonarlint.eclipse.core: C:\HCSC\EclipseWorkspace\sonarlint-eclipse-master\sonarlint-eclipse-master\org.sonarlint.eclipse.core\build.properties: bin.includes value(s) [org.sonarlint.eclipse.core/plugins/commons-io-1.3.2.jar, org.sonarlint.eclipse.core/plugins/commons-lang-2.6.jar, org.sonarlint.eclipse.core/plugins/pmd-apex-6.14.0.jar, org.sonarlint.eclipse.core/plugins/pmd-core-6.14.0.jar, org.sonarlint.eclipse.core/plugins/pmd-javascript-6.14.0.jar, org.sonarlint.eclipse.core/plugins/pmd-visualforce-6.14.0.jar] do not match any files. -> [Help 1]

但是它不起作用,并且出现相同的编译错误。如何添加依赖项以使mvn编译工作正常? 我什至尝试像正常的maven构建一样将依赖项直接添加到pom.xml中,但是它仍然无法通过编译。

0 个答案:

没有答案