class Blufin::YmlJavaPomWriter

Constants

APP
INTERNAL
MANAGED
MVN
PLACEHOLDER_APP_VERSION
PLACEHOLDER_ARTIFACT
PLACEHOLDER_ARTIFACT_PARENT
PLACEHOLDER_BLUFIN_VERSION
PLACEHOLDER_BUILD
PLACEHOLDER_BUILD_CLASS
PLACEHOLDER_BUILD_TYPE
PLACEHOLDER_DEPENDENCIES
PLACEHOLDER_DEPENDENCIES_MANAGED
PLACEHOLDER_DISTRIBUTION
PLACEHOLDER_GROUP
PLACEHOLDER_GROUP_PARENT
PLACEHOLDER_MODULE
PLACEHOLDER_MODULES
PLACEHOLDER_MODULE_NAME
PLACEHOLDER_MODULE_TITLE
PLACEHOLDER_PARENT
PLACEHOLDER_TITLE

Public Class Methods

new(maven_data_blufin, maven_data_app = nil, site = nil) click to toggle source

Initialize the class. @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 31
        def initialize(maven_data_blufin, maven_data_app = nil, site = nil)

            raise RuntimeError, "Expected @maven_data_blufin to be a Hash, instead got: #{maven_data_blufin.class}" if maven_data_blufin.nil? || !maven_data_blufin.is_a?(Hash)

            @maven_data_blufin = maven_data_blufin

            @dependencies_mvn     = nil
            @used_modules_sourced = []
            @used_modules_mvn     = []

            @blufin_core_libs               = @maven_data_blufin[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS]
            @blufin_core_libs_with_children = @maven_data_blufin[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_WITH_CHILDREN]

            unless maven_data_app.nil? || site.nil?

                raise RuntimeError, "Expected @@maven_data_app to be a Hash, instead got: #{maven_data_app.class}" unless maven_data_app.is_a?(Hash)

                @maven_data_app = maven_data_app

                @site                  = Blufin::SiteResolver::validate_site(site)
                @site_name             = Blufin::SiteResolver::get_site_name(@site)
                @site_name_camel_cased = Blufin::SiteResolver::get_site_name_camel_cased(@site)
                @site_title            = Blufin::SiteResolver::get_site_title(@site)
                @site_domain           = Blufin::SiteResolver::get_site_domain(@site)
                @site_location         = "#{Blufin::SiteResolver::get_site_location(@site)}/"

                @app_core_libs               = @maven_data_app[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS]
                @app_core_libs_with_children = @maven_data_app[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_WITH_CHILDREN]

            end

            @template_tests = <<TEMPLATE
        <!-- TEST -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
TEMPLATE

            @template_build = <<TEMPLATE
    <build>
        <plugins>
            <!-- This Plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <DependencyConvergence />
                                <requireMavenVersion>
                                    <version>3.6.0</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
#{PLACEHOLDER_BUILD_TYPE}
        </plugins>
    </build>
TEMPLATE

            @template_build_private = <<TEMPLATE
            <!-- This Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <argLine>-Duser.language=en -Duser.region=US</argLine>
                    <parallel>classes</parallel>
                    <threadCount>8</threadCount>
                    <perCoreThreadCount>true</perCoreThreadCount>
                </configuration>
            </plugin>
            <!-- This Plugin looks for bugs in your code. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.4</version>
                <configuration>
                    <effort>Max</effort>
                    <threshold>Default</threshold>
                    <xmlOutput>true</xmlOutput>
                    <excludeFilterFile>${basedir}/../findbugs-exclude.xml</excludeFilterFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- This Plugin builds byte-code/binary '.jar' files. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
TEMPLATE

            @template_build_public = <<TEMPLATE
            <!-- This Plugin is used to compile the sources of your project (required for Maven Central). -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- This Plugin is used to compile the java-docs of your project (required for Maven Central). -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- This Plugin does the PGP/GPG signing (required for Maven Central). -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- The Nexus Staging Maven Plugin is the recommended way to deploy your components to OSSRH and release them to the Central Repository. -->
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.7</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>
            <!-- https://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment-with-the-maven-release-plugin -->
            <!--
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
            -->
TEMPLATE

            @template_distribution_management = <<TEMPLATE


    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.7</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>
        </plugins>
    </build>
TEMPLATE

            @template_blufin_parent = <<TEMPLATE

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/>
    </parent>

    <groupId>org.blufin</groupId>
    <artifactId>blufin</artifactId>
    <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
    <packaging>pom</packaging>

    <name>Blufin Parent</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <modules>
#{PLACEHOLDER_MODULES}
    </modules>#{PLACEHOLDER_DISTRIBUTION}
</project>
TEMPLATE

            @template_blufin_parent_nested = <<TEMPLATE
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>
        <groupId>org.blufin</groupId>
        <artifactId>blufin</artifactId>
        <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
    </parent>

    <groupId>#{PLACEHOLDER_GROUP}</groupId>
    <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
    <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
    <packaging>pom</packaging>

    <name>#{PLACEHOLDER_MODULE_TITLE}</name>

    <modules>
#{PLACEHOLDER_MODULES}
    </modules>

</project>
TEMPLATE

            @template_blufin_children = <<TEMPLATE
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>
        <groupId>#{PLACEHOLDER_GROUP}</groupId>
        <artifactId>#{PLACEHOLDER_PARENT}</artifactId>
        <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
    </parent>

    <groupId>#{PLACEHOLDER_GROUP}</groupId>
    <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
    <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>     

    <name>#{PLACEHOLDER_MODULE_TITLE}</name>#{PLACEHOLDER_DEPENDENCIES_MANAGED}

    <dependencies>
#{PLACEHOLDER_DEPENDENCIES}#{@template_tests}    </dependencies>

#{@template_build}
</project>
TEMPLATE

            @template_app_parent = <<TEMPLATE
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/>
    </parent>

    <groupId>#{PLACEHOLDER_GROUP}</groupId>
    <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
    <version>#{PLACEHOLDER_APP_VERSION}</version>
    <packaging>pom</packaging>

    <name>#{PLACEHOLDER_TITLE} Infrastructure</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <modules>
#{PLACEHOLDER_MODULES}
    </modules>

</project>
TEMPLATE

            @template_app_parent_nested = <<TEMPLATE
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>
        <groupId>#{PLACEHOLDER_GROUP_PARENT}</groupId>
        <artifactId>#{PLACEHOLDER_ARTIFACT_PARENT}</artifactId>
        <version>#{PLACEHOLDER_APP_VERSION}</version>
    </parent>

    <groupId>#{PLACEHOLDER_GROUP}</groupId>
    <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
    <version>#{PLACEHOLDER_APP_VERSION}</version>
    <packaging>pom</packaging>

    <name>#{PLACEHOLDER_MODULE_TITLE}</name>

    <modules>
#{PLACEHOLDER_MODULES}
    </modules>

</project>
TEMPLATE

            @template_app_children = <<TEMPLATE
<?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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>#{PLACEHOLDER_GROUP}</groupId>
        <artifactId>#{PLACEHOLDER_ARTIFACT_PARENT}</artifactId>
        <version>#{PLACEHOLDER_APP_VERSION}</version>
    </parent>

    <groupId>#{PLACEHOLDER_GROUP}</groupId>
    <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
    <version>#{PLACEHOLDER_APP_VERSION}</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>     

    <name>#{PLACEHOLDER_TITLE}</name>#{PLACEHOLDER_DEPENDENCIES_MANAGED}

    <dependencies>
#{PLACEHOLDER_DEPENDENCIES}#{@template_tests}    </dependencies>

#{PLACEHOLDER_BUILD}
</project>
TEMPLATE

            @template_app_build_service = <<TEMPLATE
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <phase>package</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <DependencyConvergence />
                                <requireMavenVersion>
                                    <version>3.6.0</version>
                                </requireMavenVersion>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.4</version>
                <configuration>
                    <effort>Max</effort>
                    <threshold>Default</threshold>
                    <xmlOutput>false</xmlOutput>
                    <excludeFilterFile>${basedir}/../findbugs-exclude.xml</excludeFilterFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <argLine>-Duser.language=en -Duser.region=US</argLine>
                    <parallel>classes</parallel>
                    <threadCount>8</threadCount>
                    <perCoreThreadCount>true</perCoreThreadCount>
                </configuration>
            </plugin>
        </plugins>
    </build>
TEMPLATE

            @template_app_build_lib = <<TEMPLATE
    <build>
        <plugins>
            <!-- This Plugin is used to compile the sources of your project. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <phase>package</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <DependencyConvergence />
                                <requireMavenVersion>
                                    <version>3.6.0</version>
                                </requireMavenVersion>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
           <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.4</version>
                <configuration>
                    <effort>Max</effort>
                    <threshold>Default</threshold>
                    <xmlOutput>false</xmlOutput>
                    <excludeFilterFile>${basedir}/../findbugs-exclude.xml</excludeFilterFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- This Plugin builds byte-code/binary '.jar' files. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <argLine>-Duser.language=en -Duser.region=US</argLine>
                    <parallel>classes</parallel>
                    <threadCount>8</threadCount>
                    <perCoreThreadCount>true</perCoreThreadCount>
                </configuration>
            </plugin>
        </plugins>
    </build>
TEMPLATE

        end

Public Instance Methods

write_poms_app() click to toggle source

Write the POMs in for the individual application(s). @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 652
def write_poms_app
    raise RuntimeError, '@maven_data_app cannot be nil.' if @maven_data_app.nil?
    write_poms_app_parent
    write_poms_app_parent_nested
    write_poms_app_children
end
write_poms_blufin(path_framework = nil) click to toggle source

Write the POMs in for the blufin libs. @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 632
def write_poms_blufin(path_framework = nil)
    raise RuntimeError, '@maven_data_blufin cannot be nil.' if @maven_data_blufin.nil?
    @root_path             = path_framework.nil? ? Blufin::Config::get_path('Paths', 'BlufinJava') : path_framework
    @config_file_blufin    = "#{@root_path}/pom.xml"
    @blufin_public_modules = nil

    # Get the path(s) to ignore when copying to Framework.
    # At this point all the files should've been copied over and we know what path(s) exist.
    if path_framework
        @blufin_public_modules = []
        Blufin::Files::get_dirs_in_dir(path_framework).each { |path| @blufin_public_modules << path.split('/')[path.split('/').length - 1] }
    end

    write_poms_blufin_parent(path_framework)
    write_poms_blufin_parent_nested(path_framework)
    write_poms_blufin_children(path_framework)
end

Private Instance Methods

add_dependencies(dep_string, deps, type, maven_data = nil) click to toggle source

Adds Dependencies to string. @return string

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 889
        def add_dependencies(dep_string, deps, type, maven_data = nil)
            maven_data = @maven_data_blufin if maven_data.nil?
            case type
                when MANAGED
                    output = ''
                    maven_data[Blufin::YmlMavenValidator::DEPENDENCIES_MVN].each do |dependency_version|
                        output += <<TEMPLATE
            <dependency>
                <groupId>#{dependency_version[0][Blufin::YmlMavenValidator::DEPENDENCIES_GROUP_ID]}</groupId>
                <artifactId>#{dependency_version[1][Blufin::YmlMavenValidator::DEPENDENCIES_ARTIFACT_ID]}</artifactId>
                <version>#{dependency_version[2][Blufin::YmlMavenValidator::DEPENDENCIES_VERSION]}</version>
            </dependency>
TEMPLATE
                    end
                    return output
                when APP
                    dep_string += "        <!-- #{@site_name.upcase} -->\n"
                when INTERNAL
                    dep_string += "        <!-- INTERNAL -->\n"
                when MVN
                    dep_string += "        <!-- MVN -->\n"
                else
                    raise RuntimeError, "Unrecognized type: #{type}"
            end
            deps.each do |dep|
                module_name = nil
                exclude     = nil
                test_scope  = nil
                test_jar    = nil
                dep.each do |dep_inner|
                    dep_inner.each do |key, data|
                        case key
                            when Blufin::YmlMavenValidator::DEPENDENCIES_USE
                                module_name = data
                            when Blufin::YmlMavenValidator::DEPENDENCIES_EXCLUDE
                                exclude = data
                            when Blufin::YmlMavenValidator::DEPENDENCIES_TEST_SCOPE
                                test_scope = data
                            when Blufin::YmlMavenValidator::DEPENDENCIES_TEST_JAR
                                test_jar = data
                            else
                                raise RuntimeError, "Unrecognized key: #{key}"
                        end
                    end
                end
                raise RuntimeError, ":use should never be nil but was for: #{deps.inspect}" if module_name.nil?
                case type
                    when APP
                        fm       = nil
                        group    = nil
                        artifact = nil
                        @app_core_libs_with_children.each do |core_lib_with_child|
                            if module_name =~ /\A#{core_lib_with_child}-/
                                group_suffix = core_lib_with_child.gsub(/\A#{@site_name}-/, '')
                                fm           = true
                                artifact     = module_name
                                group        = "#{@site_domain}.#{@site_name.gsub('-', '.')}.#{group_suffix}".gsub(/^\./, '')
                            end
                        end
                        if fm.nil?
                            group    = "#{@site_domain}.#{@site_name.gsub('-', '.')}".gsub(/^\./, '')
                            artifact = module_name
                        end
                        version = get_app_version
                    when INTERNAL
                        fm       = nil
                        group    = nil
                        artifact = nil
                        @blufin_core_libs_with_children.each do |core_lib_with_child|
                            if module_name =~ /\A#{core_lib_with_child}-/
                                group_suffix = core_lib_with_child.gsub(/\Ablufin-/, '')
                                fm           = true
                                artifact     = module_name
                                group        = "org.blufin.#{group_suffix.gsub('-', '.')}"
                            end
                        end
                        if fm.nil?
                            group    = 'org.blufin'
                            artifact = module_name
                        end
                        version = get_blufin_version
                    when MVN
                        @used_modules_mvn << module_name
                        data     = maven_data[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_MVN_CACHE][module_name]
                        group    = data[:group]
                        artifact = data[:artifact]
                        version  = data[:version]
                    else
                        raise RuntimeError, "Unrecognized type: #{type}"
                end
                raise RuntimeError, 'group should never be nil!' if group.nil?
                raise RuntimeError, 'artifact should never be nil!' if artifact.nil?
                raise RuntimeError, 'version should never be nil!' if version.nil?
                dep_string += <<TEMPLATE
        <dependency>
            <groupId>#{group}</groupId>
            <artifactId>#{artifact}</artifactId>
            <version>#{version}</version>
TEMPLATE

                unless test_jar.nil?
                    dep_string += <<TEMPLATE
            <type>test-jar</type>
TEMPLATE
                end

                unless test_scope.nil?
                    dep_string += <<TEMPLATE
            <scope>test</scope>
TEMPLATE
                end

                # Add Exclusions (if any).
                unless exclude.nil?
                    if exclude.is_a?(Array) && exclude.length > 0
                        dep_string += "            <exclusions>\n"
                        exclude.each do |ex|
                            ex_split = ex.split(':')
                            raise RuntimeError, "#{ex} is wrong format, should have exactly one colon [:]. We must write validation for this." unless ex_split.length == 2
                            dep_string += <<TEMPLATE
                <exclusion>
                    <groupId>#{ex_split[0]}</groupId>
                    <artifactId>#{ex_split[1]}</artifactId>
                </exclusion>
TEMPLATE
                        end
                        dep_string += "            </exclusions>\n"
                    end
                end
                dep_string += <<TEMPLATE
        </dependency>
TEMPLATE
            end
            dep_string
        end
get_app_version() click to toggle source

Returns APP version. @return String

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 1039
def get_app_version
    begin
        v = @maven_data_app[Blufin::YmlMavenValidator::CONFIG][@site_name][Blufin::YmlMavenValidator::CONFIG_APP_VERSION]
        raise RuntimeError if v.nil? || v.to_s.length <= 0
        return v
    rescue
        raise RuntimeError, "Could not determine #{@site_title} version."
    end
end
get_blufin_version() click to toggle source

Returns BLUFIN version. @return String

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 1027
def get_blufin_version
    begin
        v = @maven_data_blufin[Blufin::YmlMavenValidator::CONFIG][Blufin::YmlMavenValidator::CONFIG_BLUFIN][Blufin::YmlMavenValidator::CONFIG_BLUFIN_VERSION]
        raise RuntimeError if v.nil? || v.to_s.length <= 0
        return v
    rescue
        raise RuntimeError, 'Could not determine Blufin version.'
    end
end
write_poms_app_children() click to toggle source

Writes the APP child POMs. @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 828
def write_poms_app_children
    module_data = {}
    @maven_data_app[@site_name].keys.each do |app_module|
        data     = {}
        fm       = nil
        group    = "#{@site_domain}.#{@site_name.gsub('-', '.')}".gsub(/^\./, '')
        location = "#{@site_location}/#{Blufin::YmlMavenValidator::APP_INFRASTRUCTURE}".gsub('//', '/')
        @app_core_libs_with_children.each do |core_lib_with_child|
            if app_module =~ /\A#{core_lib_with_child}-/
                group_suffix  = core_lib_with_child.gsub(/\A#{@site_name}-/, '')
                fm            = true
                data[:pom]    = "#{location}/#{core_lib_with_child}/#{app_module}/pom.xml"
                data[:name]   = app_module
                data[:group]  = "#{group}.#{group_suffix}"
                data[:parent] = "#{@site_name}-#{group_suffix}"
                break
            end
        end
        if fm.nil?
            data[:pom]    = "#{location}/#{app_module}/pom.xml"
            data[:name]   = app_module
            data[:group]  = group
            data[:parent] = "#{@site_name}"
        end
        type_split              = data[:name].split('-')
        type                    = type_split[type_split.length - 1]
        data[:title]            = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::BLUFIN_TITLE]
        data[:deps_app]         = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::DEPENDENCIES_APP]
        data[:deps_internal]    = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::DEPENDENCIES_BLUFIN]
        data[:deps_mvn]         = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::DEPENDENCIES_MVN]
        module_data[app_module] = data
        dep_string              = ''
        dep_string              = add_dependencies(dep_string, data[:deps_app], APP, @maven_data_app) if !data[:deps_app].nil? && data[:deps_app].length > 0
        dep_string              = add_dependencies(dep_string, data[:deps_internal], INTERNAL, @maven_data_app) if !data[:deps_internal].nil? && data[:deps_internal].length > 0
        dep_string              = add_dependencies(dep_string, data[:deps_mvn], MVN, @maven_data_app) if !data[:deps_mvn].nil? && data[:deps_mvn].length > 0
        contents                = @template_app_children
        contents                = contents.gsub(PLACEHOLDER_GROUP, data[:group])
        contents                = contents.gsub(PLACEHOLDER_ARTIFACT, data[:name])
        contents                = contents.gsub(PLACEHOLDER_ARTIFACT_PARENT, data[:parent])
        contents                = contents.gsub(PLACEHOLDER_APP_VERSION, get_app_version)
        contents                = contents.gsub(PLACEHOLDER_TITLE, data[:title])
        contents                = contents.gsub(PLACEHOLDER_DEPENDENCIES, dep_string)
        contents                = contents.gsub(PLACEHOLDER_DEPENDENCIES_MANAGED, "\n\n    <dependencyManagement>\n        <dependencies>\n#{add_dependencies('', nil, MANAGED, @maven_data_app)}        </dependencies>\n    </dependencyManagement>")
        if [
            Blufin::YmlMavenValidator::APP_INFRASTRUCTURE_API,
            Blufin::YmlMavenValidator::APP_INFRASTRUCTURE_CRON,
            Blufin::YmlMavenValidator::APP_INFRASTRUCTURE_WORKER,
        ].include?(type)
            build_string = @template_app_build_service
            build_string = build_string.gsub(PLACEHOLDER_MODULE, type.downcase)
            build_string = build_string.gsub(PLACEHOLDER_BUILD_CLASS, "#{@site_name_camel_cased}#{type.capitalize}")
            contents     = contents.gsub(PLACEHOLDER_BUILD, build_string)
        else
            contents = contents.gsub(PLACEHOLDER_BUILD, @template_app_build_lib)
        end
        Blufin::Files::write_file(data[:pom], Blufin::YmlCommon::convert_string_to_line_array(contents))
    end
end
write_poms_app_parent() click to toggle source

Writes the APP parent POM. @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 773
def write_poms_app_parent
    app_modules        = []
    app_modules_string = ''
    @maven_data_app[@site_name].keys.each do |app_module|
        fm = nil
        @app_core_libs_with_children.each do |core_lib_with_child|
            if app_module =~ /\A#{core_lib_with_child}-/
                fm = true
                app_modules << "<module>#{core_lib_with_child}</module>"
                break
            end
        end
        app_modules << "<module>#{app_module}</module>" if fm.nil?
    end
    app_modules.uniq!
    app_modules.each { |nm| app_modules_string += "        #{nm}\n" }
    site_name_with_dots = @site_name.gsub('-', '.')
    contents            = @template_app_parent
    contents            = contents.gsub(PLACEHOLDER_GROUP, "#{@site_domain}.#{site_name_with_dots}".gsub(/^\./, ''))
    contents            = contents.gsub(PLACEHOLDER_ARTIFACT, "#{@site_name}")
    contents            = contents.gsub(PLACEHOLDER_APP_VERSION, get_app_version)
    contents            = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
    contents            = contents.gsub(PLACEHOLDER_TITLE, @site_title)
    contents            = contents.gsub(PLACEHOLDER_MODULES, app_modules_string.gsub(/\n\z/, ''))
    Blufin::Files.write_file("#{@site_location}/#{Blufin::YmlMavenValidator::APP_INFRASTRUCTURE}/pom.xml", Blufin::YmlCommon::convert_string_to_line_array(contents))
end
write_poms_app_parent_nested() click to toggle source

Writes the APP nested parent POM(s). @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 802
def write_poms_app_parent_nested
    @app_core_libs_with_children.each do |core_lib_with_child|
        group_suffix          = core_lib_with_child.gsub(/\A#{@site_name}-/, '')
        nested_path           = "#{@site_name}-#{group_suffix}"
        nested_modules_string = ''
        @maven_data_app[@site_name].each do |app_module, module_data|
            if module_data.has_key?(Blufin::YmlMavenValidator::BLUFIN_PARENT) && module_data[Blufin::YmlMavenValidator::BLUFIN_PARENT] == core_lib_with_child
                nested_modules_string += "        <module>#{app_module}</module>\n"
                next
            end
        end
        site_name_with_dots = @site_name.gsub('-', '.')
        contents            = @template_app_parent_nested
        contents            = contents.gsub(PLACEHOLDER_GROUP, "#{@site_domain}.#{site_name_with_dots}.#{group_suffix}".gsub(/^\./, ''))
        contents            = contents.gsub(PLACEHOLDER_GROUP_PARENT, "#{@site_domain}.#{site_name_with_dots}".gsub(/^\./, ''))
        contents            = contents.gsub(PLACEHOLDER_ARTIFACT, "#{@site_name}-#{group_suffix}")
        contents            = contents.gsub(PLACEHOLDER_ARTIFACT_PARENT, "#{@site_name}")
        contents            = contents.gsub(PLACEHOLDER_APP_VERSION, get_app_version)
        contents            = contents.gsub(PLACEHOLDER_MODULES, nested_modules_string.gsub(/\n\z/, ''))
        contents            = contents.gsub(PLACEHOLDER_MODULE_TITLE, @maven_data_app[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_PARENTS][nested_path][:title])
        Blufin::Files.write_file("#{@site_location}/#{Blufin::YmlMavenValidator::APP_INFRASTRUCTURE}/#{nested_path}/pom.xml", Blufin::YmlCommon::convert_string_to_line_array(contents))
    end
end
write_poms_blufin_children(path_framework = nil) click to toggle source

Writes the BLUFIN child POMs. @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 714
def write_poms_blufin_children(path_framework = nil)
    module_data = {}
    @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN].keys.each do |blufin_module|

        # If generating framework and module path does not exist (IE: blufin-blank), then skip.
        next unless @blufin_public_modules.nil? || @blufin_public_modules.include?(blufin_module)

        data = {}
        fm   = nil
        @blufin_core_libs_with_children.each do |core_lib_with_child|
            if blufin_module =~ /\A#{core_lib_with_child}-/
                group_suffix  = core_lib_with_child.gsub(/\Ablufin-/, '')
                fm            = true
                data[:pom]    = "#{@root_path}/#{core_lib_with_child}/#{blufin_module}/pom.xml"
                data[:name]   = blufin_module
                data[:group]  = "org.blufin.#{group_suffix.gsub('-', '.')}"
                data[:parent] = "blufin-#{group_suffix}"
                break
            end
        end
        if fm.nil?
            data[:pom]    = "#{@root_path}/#{blufin_module}/pom.xml"
            data[:name]   = blufin_module
            data[:group]  = 'org.blufin'
            data[:parent] = 'blufin'
        end
        data[:title]               = @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN][blufin_module][Blufin::YmlMavenValidator::BLUFIN_TITLE]
        data[:deps_internal]       = @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN][blufin_module][Blufin::YmlMavenValidator::DEPENDENCIES_BLUFIN]
        data[:deps_mvn]            = @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN][blufin_module][Blufin::YmlMavenValidator::DEPENDENCIES_MVN]
        module_data[blufin_module] = data
        dep_string                 = ''
        dep_string                 = add_dependencies(dep_string, data[:deps_internal], INTERNAL) if !data[:deps_internal].nil? && data[:deps_internal].length > 0
        dep_string                 = add_dependencies(dep_string, data[:deps_mvn], MVN) if !data[:deps_mvn].nil? && data[:deps_mvn].length > 0
        contents                   = @template_blufin_children
        contents                   = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
        contents                   = contents.gsub(PLACEHOLDER_GROUP, data[:group])
        contents                   = contents.gsub(PLACEHOLDER_PARENT, data[:parent])
        contents                   = contents.gsub(PLACEHOLDER_ARTIFACT, data[:name])
        contents                   = contents.gsub(PLACEHOLDER_MODULE_TITLE, data[:title])
        contents                   = contents.gsub(PLACEHOLDER_DEPENDENCIES, dep_string)
        contents                   = contents.gsub(PLACEHOLDER_DEPENDENCIES_MANAGED, "\n\n    <dependencyManagement>\n        <dependencies>\n#{add_dependencies('', nil, MANAGED)}        </dependencies>\n    </dependencyManagement>")
        contents                   = contents.gsub(PLACEHOLDER_BUILD_TYPE, path_framework.nil? ? @template_build_private : @template_build_public)
        Blufin::Files::write_file(data[:pom], Blufin::YmlCommon::convert_string_to_line_array(contents))
    end

    @used_modules_sourced.sort!.uniq!
    @used_modules_mvn.sort!.uniq!

    @maven_data_blufin[Blufin::YmlMavenValidator::DEPENDENCIES_MVN].each do |dependency|
        # TODO - 03/10/19 - Turns out the unused dependencies are needed otherwise we get dependency convergence error(s) during the maven builds... Possibly add flag -> ignore-unused: true ?
        # dep_extracted = Blufin::YmlCommon::extract_group_artifact_version_from_array(dependency)
        # dep_module    = "#{dep_extracted[Blufin::YmlMavenValidator::DEPENDENCIES_GROUP_ID]}:#{dep_extracted[Blufin::YmlMavenValidator::DEPENDENCIES_ARTIFACT_ID]}"
        # Blufin::Terminal::output("Found unused #{ Blufin::Terminal::format_action('mvn')} dependency \xe2\x86\x92 #{Blufin::Terminal::format_highlight(dep_module)}", Blufin::Terminal::MSG_WARNING) unless @used_modules_mvn.include?(dep_module)
    end

end
write_poms_blufin_parent(path_framework = nil) click to toggle source

Writes the BLUFIN parent POM. @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 663
def write_poms_blufin_parent(path_framework = nil)
    blufin_modules        = []
    blufin_modules_string = ''
    @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN].keys.each do |blufin_module|

        # If generating framework and module path does not exist (IE: blufin-blank), then skip.
        next unless @blufin_public_modules.nil? || @blufin_public_modules.include?(blufin_module)

        fm = nil
        @blufin_core_libs_with_children.each do |core_lib_with_child|
            if blufin_module =~ /\A#{core_lib_with_child}-/
                fm = true
                blufin_modules << "<module>#{core_lib_with_child}</module>"
                break
            end
        end
        blufin_modules << "<module>#{blufin_module}</module>" if fm.nil?
    end
    blufin_modules.uniq!
    blufin_modules.each { |nm| blufin_modules_string += "        #{nm}\n" }
    contents = @template_blufin_parent
    contents = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
    contents = contents.gsub(PLACEHOLDER_MODULES, blufin_modules_string.gsub(/\n\z/, ''))
    contents = contents.gsub(PLACEHOLDER_DISTRIBUTION, path_framework.nil? ? "\n" : @template_distribution_management)
    Blufin::Files.write_file(@config_file_blufin, Blufin::YmlCommon::convert_string_to_line_array(contents))
end
write_poms_blufin_parent_nested(path_framework = nil) click to toggle source

Writes the BLUFIN nested parent POM(s). @return void

# File lib/core/yml_writers/yml_java_pom_writer.rb, line 692
def write_poms_blufin_parent_nested(path_framework = nil)
    @blufin_core_libs_with_children.each do |core_lib_with_child|
        group_suffix          = core_lib_with_child.gsub(/\Ablufin-/, '')
        nested_modules_string = ''
        @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN].each do |blufin_module, module_data|
            if module_data.has_key?(Blufin::YmlMavenValidator::BLUFIN_PARENT) && module_data[Blufin::YmlMavenValidator::BLUFIN_PARENT] == core_lib_with_child
                nested_modules_string += "        <module>#{blufin_module}</module>\n"
                next
            end
        end
        contents = @template_blufin_parent_nested
        contents = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
        contents = contents.gsub(PLACEHOLDER_GROUP, "org.blufin.#{group_suffix.gsub('-', '.')}")
        contents = contents.gsub(PLACEHOLDER_ARTIFACT, "blufin-#{group_suffix}")
        contents = contents.gsub(PLACEHOLDER_MODULES, nested_modules_string.gsub(/\n\z/, ''))
        contents = contents.gsub(PLACEHOLDER_MODULE_TITLE, @maven_data_blufin[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_PARENTS]["blufin-#{group_suffix}"][:title])
        Blufin::Files.write_file("#{@root_path}/#{core_lib_with_child}/pom.xml", Blufin::YmlCommon::convert_string_to_line_array(contents))
    end
end