xiaodududu / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Problematic profile activation in extensions-parent #612

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Within the extensions-parent there is a profile defined, that seems to be 
activated by default.
At least I get an error () when calling "mvn bundle:bundleall" in a project 
that has a dependency to guice-multibindings (3.0-rc2):

[ERROR] Failed to execute goal 
org.apache.felix:maven-bundle-plugin:2.3.4:bundleall (default-cli) on project 
bundle2: Artifact was not found in the 
repocom.google.inject:guice:jar:no_deps:3.0-rc2:compile: Failure to find 
com.google.inject:guice:jar:no_deps:3.0-rc2 in 
http://nexus.cedarsoft.com/content/repositories/central was cached in the local 
repository, resolution will not be reattempted until the update interval of 
Nexus central has elapsed or updates are forced

 <profiles>
    <profile>
      <!--
       | JarJar build profile: re-package ASM and CGLIB references under the Guice namespace
      -->
      <id>guice.with.jarjar</id>
      <activation>
        <property>
          <name>guice.with.jarjar</name>
          <value>!false</value>
        </property>
      </activation>
      <dependencies>
        <!--
         | Extensions compile first against the non-JarJar'd core - and are then JarJar'd themselves
         | (optional dependency so it doesn't leak to client projects that depend on Guice artifacts)
        -->
        <dependency>
          <groupId>com.google.inject</groupId>
          <artifactId>guice</artifactId>
          <version>${project.version}</version>
          <classifier>no_deps</classifier>
          <optional>true</optional>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>jarjar-maven-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>*:*</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

Original issue reported on code.google.com by js.cedar...@gmail.com on 5 Mar 2011 at 7:59

GoogleCodeExporter commented 9 years ago
This dependency is correct - the extensions need to compile against the 
pre-jarjar'd build of Guice before they are jarjar'd themselves. This 
particular build artifact is not uploaded to Maven central to avoid people 
depending on it by mistake, but because it's an optional dependency (used only 
at compile time) it won't affect people using the individual extension 
artifacts.

The bug here is in the bundleall goal of the maven-bundle-plugin which appears 
to ignore the optional setting on the dependency and treats it as required. 
Personally I would avoid using the bundleplugin's bundleall goal and use 
something like Embed-Dependency to wrap jars into bundles, because a) the 
specific bundleall goal is no longer maintained b) the bundles it creates have 
poor OSGi metadata and c) you lose the inter-dependency information between the 
wrapped bundles.

PS Guice and its extensions already have OSGi metadata already and don't need 
to be "bundlized".

Original comment by mccu...@gmail.com on 6 Mar 2011 at 1:18