0

我正在开发一个 eclipse 插件,我需要使用 tools.jar 作为依赖项。正如我们所知,eclipse 不会将普通 jar 作为依赖项。所以我尝试将 jar 更改为 osgi bundle。但是生成的 osgi bundle 里面不包含 com.sun 包。

<dependency>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
        <version>1.7.0</version>
        <scope>system</scope>
        <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency> 

我试图捆绑 pom.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nuwaza.aqua</groupId>
<artifactId>osgi-tool-bundle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>

<dependencies>
    <dependency>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
        <version>1.7.0</version>
        <scope>system</scope>
        <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
    </dependency>
     <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>4.3.0</version>
    </dependency> 
</dependencies>
<build>
    <plugins>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>1.4.0</version>
            <extensions>true</extensions>
            <configuration>
                <manifestLocation>META-INF</manifestLocation>
                <instructions>
                    <Bundle-SymbolicName>osgi-tool-bundle</Bundle-SymbolicName>                     
                    <Bundle-Name>osgi-tool-bundle</Bundle-Name>
                    <Bundle-Version>1.0.0</Bundle-Version>
                    <Export-Package>*</Export-Package>
                    <Private-Package>com.nuwaza.aqua.bundle</Private-Package>
                    <Bundle-Activator>com.nuwaza.aqua.bundle.Activator</Bundle-Activator>
                    <Import-Package>*;resolution:=optional</Import-Package>
                    <Embed-Dependency>*;scope=compile|runtime|system</Embed-Dependency>                 
                    <Embed-Directory>target/dependency</Embed-Directory>
                    <Embed-StripGroup>true</Embed-StripGroup>
                    <Embed-Transitive>true</Embed-Transitive>
                </instructions>
            </configuration>
        </plugin>



        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                </execution>
             </executions>
          </plugin>
        <profiles>
        <profile>
          <activation>
              <property>
                <name>m2e.version</name>
            </property>
        </activation>
        <properties>
            <osgi-version-qualifier>qualifier</osgi-version-qualifier>
        </properties>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <configuration>
                            <!-- PDE does not honour custom manifest location -->
                            <manifestLocation>META-INF</manifestLocation>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </profile>
</profiles>

生成的包只包含org.osgi包而不是com.sun包。我什至在<Embed-Dependency>*;scope=compile|runtime|system</Embed-Dependency>.

我错过了什么?

4

0 回答 0