<?xml version="1.0"?>
<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>
  <parent>
    <artifactId>jruby-maven-plugins</artifactId>
    <groupId>org.jruby.maven</groupId>
    <version>3.0.6</version>
  </parent>
  <artifactId>ruby-tools</artifactId>
  <version>3.0.6</version>
  <name>Ruby Tools</name>
  <dependencies>
    <dependency>
      <groupId>org.jruby</groupId>
      <artifactId>jruby-complete</artifactId>
      <version>${jruby.version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
      <version>1.10.11</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-velocity</artifactId>
      <version>1.3</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-component-annotations</artifactId>
      <version>${plexus.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-container-default</artifactId>
      <version>${plexus.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-classworlds</artifactId>
      <version>2.6.0</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>3.4.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-model</artifactId>
      <version>${maven.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-archiver</artifactId>
      <version>4.8.0</version>
    </dependency>
    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
      <version>1.31</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <version>${maven.version}</version>
      <optional>true</optional>
      <!--scope>provided</scope-->
    </dependency>
  </dependencies>
  <properties>
    <jruby.versions>9.4.13.0</jruby.versions>
    <plexus.version>1.5.4</plexus.version>
    <root.dir>${basedir}/..</root.dir>
    <gem.home>${root.dir}/target/rubygems</gem.home>
    <gem.path>${root.dir}/target/rubygems</gem.path>
  </properties>
  <build>
      <resources>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
	<artifactId>maven-dependency-plugin</artifactId> 
	<version>2.8</version>
	<executions>
          <execution>
            <id>copy jruby</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.jruby</groupId>
                  <artifactId>jruby-complete</artifactId>
                  <version>${jruby.version}</version>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
	      </artifactItems>
	    </configuration>
	  </execution>
          <execution>
            <id>copy gems</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
	      <includeTypes>gem</includeTypes>
	    </configuration>
	  </execution>
	</executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
	<executions>
	  <execution>
	    <id>install gems</id>
	    <phase>process-resources</phase>
	    <goals><goal>exec</goal></goals>
            <configuration>
              <executable>java</executable> 
              <arguments>
		<argument>-jar</argument>
		<argument>${project.build.directory}/jruby-complete-${jruby.version}.jar</argument>
		<argument>${basedir}/src/main/scripts/install_gems.rb</argument>
	      </arguments>
	    </configuration>
	  </execution>
	</executions>
      </plugin>
    </plugins>
    <pluginManagement>
    	<plugins>
    		<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
    		<plugin>
    			<groupId>org.eclipse.m2e</groupId>
    			<artifactId>lifecycle-mapping</artifactId>
    			<version>1.0.0</version>
    			<configuration>
    				<lifecycleMappingMetadata>
    					<pluginExecutions>
    						<pluginExecution>
    							<pluginExecutionFilter>
    								<groupId>org.codehaus.mojo</groupId>
    								<artifactId>
    									exec-maven-plugin
    								</artifactId>
    								<versionRange>[1.2,)</versionRange>
    								<goals>
    									<goal>exec</goal>
    								</goals>
    							</pluginExecutionFilter>
    							<action>
    								<ignore />
    							</action>
    						</pluginExecution>
    					</pluginExecutions>
    				</lifecycleMappingMetadata>
    			</configuration>
    		</plugin>
    	</plugins>
    </pluginManagement>
  </build>
  <profiles>
    <profile> 
      <!--
	 that profile looks for the development setup and then gets all the 
         needed gems from mavengem:https://rubygems.org
         this repo does not show when the pom is used from maven central
	 
	 all the gems here are embedded into the jar itself, i.e. those
	 gem dependencies are only for build time
      -->
      <id>build</id>
   
      <activation>
        <file>
          <exists>../jruby-maven-plugin</exists>
        </file>
      </activation>

      <pluginRepositories>
        <pluginRepository>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>sonatype</id>
          <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </pluginRepository>
      </pluginRepositories>

      <repositories>
        <repository>
          <id>mavengems</id>
          <url>mavengem:https://rubygems.org</url>
        </repository>
      </repositories>

      <dependencies>
        <dependency>
          <groupId>rubygems</groupId>
          <artifactId>maven-tools</artifactId>
          <version>1.2.2</version>
          <type>gem</type>
          <scope>provided</scope>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>
