<?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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.google.inject</groupId>
    <artifactId>guice-parent</artifactId>
    <version>6.0.0</version>
  </parent>

  <artifactId>guice</artifactId>

  <name>Google Guice - Core Library</name>

  <dependencies>
    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
    </dependency>
    <dependency>
      <groupId>jakarta.inject</groupId>
      <artifactId>jakarta.inject-api</artifactId>
    </dependency>
    <dependency>
      <groupId>aopalliance</groupId>
      <artifactId>aopalliance</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.errorprone</groupId>
      <artifactId>error_prone_annotations</artifactId>
      <optional>true</optional>
    </dependency>
    <!--
     | ASM is embedded by default by the JarJar build profile
    -->
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <optional>true</optional>
    </dependency>
    <!--
     | Test dependencies
    -->
    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject-tck</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava-testlib</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>biz.aQute</groupId>
      <artifactId>bnd</artifactId>
      <version>0.0.384</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.framework</artifactId>
      <version>3.0.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.truth.extensions</groupId>
      <artifactId>truth-java8-extension</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!--
       | Add standard LICENSE and NOTICE files
      -->
      <plugin>
        <artifactId>maven-remote-resources-plugin</artifactId>
      </plugin>
      <!--
       | Enable Java8 conformance checks
      -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>animal-sniffer-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <testExcludes>
            <!--
              Don't compile the jakarta TCK b/c it would clash w/ the javax.inject TCK.
              We test it with the Bazel build for now, and basic jakarta functionality is tested
              with the JakartaTest in the same package.
            -->
            <testExclude>**/GuiceJakartaTck.java</testExclude>
          </testExcludes>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!--
           | Temporarily excluded tests
          -->
          <excludes>
            <exclude>**/*$*</exclude>
            <exclude>**/OSGiContainerTest*</exclude>
            <exclude>**/ScopesTest*</exclude>
            <exclude>**/TypeConversionTest*</exclude>
          </excludes>
        </configuration>
        <executions>
          <execution>
            <id>anonymous-class-loading</id>
            <phase>test</phase>
            <goals><goal>test</goal></goals>
            <configuration>
              <!-- enable ShowHiddenFrames to help tests find AOP frames on Java17 -->
              <argLine>-Dguice_custom_class_loading=ANONYMOUS -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames</argLine>
            </configuration>
          </execution>
          <execution>
            <id>child-class-loading</id>
            <phase>test</phase>
            <goals><goal>test</goal></goals>
            <configuration>
              <argLine>-Dguice_custom_class_loading=CHILD</argLine>
            </configuration>
          </execution>
          <execution>
            <id>without-bytecode-generation</id>
            <phase>test</phase>
            <goals><goal>test</goal></goals>
            <configuration>
              <argLine>-Dguice_bytecode_gen_option=DISABLED</argLine>
            </configuration>
          </execution>
          <execution>
            <id>with-windows-line-separators</id>
            <phase>test</phase>
            <goals><goal>test</goal></goals>
            <configuration>
              <!-- enable ShowHiddenFrames to help tests find AOP frames on Java17 -->
              <argLine>-Dline.separator='\r\n' -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames</argLine>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!--
       | Add OSGi manifest
      -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
          <instructions>
            <Bundle-Name>${project.artifactId}</Bundle-Name>
            <Import-Package>!org.objectweb.asm.*,!com.google.inject.*,!javax.annotation,*</Import-Package>
            <Eclipse-ExtensibleAPI>true</Eclipse-ExtensibleAPI>
          </instructions>
        </configuration>
      </plugin>
      <!--
       | Remove duplicate jarjar'd LICENSE and NOTICE
      -->
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>LICENSE</exclude>
            <exclude>NOTICE</exclude>
          </excludes>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>com.google.guice</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <!--
       | Generate sources jar
      -->
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
      <!--
       | Generate javadoc jar
      -->
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <!--
       | JarJar build profile: Embed ASM classes under a Guice namespace
      -->
      <id>guice.with.jarjar</id>
      <activation>
        <property>
          <name>guice.with.jarjar</name>
          <value>!false</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>jarjar-maven-plugin</artifactId>
            <version>1.9</version>
            <executions>
              <execution>
                <id>jarjar</id>
                <goals><goal>jarjar</goal></goals>
              </execution>
            </executions>
            <configuration>
              <overwrite>true</overwrite>
              <includes>
                <include>*:asm*</include>
              </includes>
              <rules>
                <rule>
                  <pattern>org.objectweb.asm.*</pattern>
                  <result>com.google.inject.internal.asm.$@1</result>
                </rule>
                <rule>
                  <pattern>org.objectweb.asm.**.*</pattern>
                  <result>com.google.inject.internal.asm.@1.$@2</result>
                </rule>
                <keep>
                  <pattern>com.google.inject.**</pattern>
                </keep>
                <keep>
                  <pattern>com.googlecode.**</pattern>
                </keep>
              </rules>
            </configuration>
          </plugin>
          <plugin>
            <!--
             | Attach the original non-JarJar'd classes so extensions can compile against them
            -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.8</version>
            <executions>
              <execution>
                <id>classes</id>
                <phase>package</phase>
                <goals>
                  <goal>attach-artifact</goal>
                </goals>
                <configuration>
                  <artifacts>
                    <artifact>
                      <file>${project.build.directory}/original-${project.build.finalName}.jar</file>
                      <classifier>classes</classifier>
                    </artifact>
                  </artifacts>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!--
       | m2e profile - enable use of JarJar inside Eclipse
      -->
      <id>m2e</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.eclipse.m2e</groupId>
              <artifactId>lifecycle-mapping</artifactId>
              <version>1.0.0</version>
              <configuration>
                <lifecycleMappingMetadata>
                  <pluginExecutions>
                    <pluginExecution>
                      <pluginExecutionFilter>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>jarjar-maven-plugin</artifactId>
                        <versionRange>[1.4,)</versionRange>
                        <goals><goal>jarjar</goal></goals>
                      </pluginExecutionFilter>
                      <action><execute /></action>
                    </pluginExecution>
                  </pluginExecutions>
                </lifecycleMappingMetadata>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>
</project>
