Commit 245a5140 authored by Ole Hejlskov's avatar Ole Hejlskov
Browse files

Close the loop on 4.2 support and Solr

parent 3630cced
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@
                        <atomic>true</atomic>
                        <stored>false</stored>
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                    </index>
                    <constraints>
                        <constraint ref="acme:securityClassificationOptions"/>
+0 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@
                        <atomic>true</atomic>
                        <stored>false</stored>
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                    </index>
                    <constraints>
                        <constraint ref="acme:securityClassificationOptions"/>
+167 −28
Original line number Diff line number Diff line
@@ -475,9 +475,17 @@ public abstract class AbstractRunMojo extends AbstractMojo {
                                        element(name("token"), "@@ALFRESCO_SOLR4_DATA_DIR@@"),
                                        element(name("value"), "${solrDataDir}/index")
                                ),
                                element(name("replacement"),
                                        element(name("token"), "@@ALFRESCO_SOLR_DIR@@"),
                                        element(name("value"), "${solrDataDir}/index")
                                ),
                                element(name("replacement"),
                                        element(name("token"), "alfresco.port=8080"),
                                        element(name("value"), "alfresco.port=" + getPort())
                                ),
                                element(name("replacement"),
                                        element(name("token"), "alfresco.secureComms=https"),
                                        element(name("value"), "alfresco.secureComms=none")
                                )

                        )
@@ -495,6 +503,93 @@ public abstract class AbstractRunMojo extends AbstractMojo {
    protected void installSolr10InLocalRepo() throws MojoExecutionException {
        if (isPlatformVersionLtOrEqTo42()) {
            getLog().info("Installing Solr 1.0 WAR in local Maven repo");
            File solrWarSource = new File( solrHome + "/apache-solr-1.4.1.war" );
            File outputDir = new File( project.getBuild().getDirectory() + "/solr");
            if (outputDir.exists()) {
                getLog().info("Solr build dir: "+ outputDir +" already exists, not rebuilding");
                return;
            }

            ZipUtil.unpack( solrWarSource, outputDir );

            // Comment out SSL/security requirements
            executeMojo(
                    plugin(
                            groupId("com.google.code.maven-replacer-plugin"),
                            artifactId("replacer"),
                            version(MAVEN_REPLACER_PLUGIN_VERSION)
                    ),
                    goal("replace"),
                    configuration(
                            element(name("regex"), "false"),
                            element(name("includes"),
                                    element(name("include"), outputDir + "/WEB-INF/web.xml")
                            ),
                            element(name("replacements"),
                                    element(name("replacement"),
                                            element(name("token"), "<!-- <security-constraint>"),
                                            element(name("value"), "<security-constraint>")
                                    ),
                                    element(name("replacement"),
                                            element(name("token"), "</security-role> -->"),
                                            element(name("value"), "</security-role>")
                                    ),

                                    element(name("replacement"),
                                            element(name("token"), "<security-constraint>"),
                                            element(name("value"), "<!-- <security-constraint>")
                                    ),
                                    element(name("replacement"),
                                            element(name("token"), "</security-role>"),
                                            element(name("value"), "</security-role> -->")
                                    )
                            )
                    ),
                    execEnv
            );

            executeMojo(
                    plugin(
                            groupId("com.coderplus.maven.plugins"),
                            artifactId("copy-rename-maven-plugin"),
                            version("1.0")
                    ),
                    goal("copy"),
                    configuration(
                            element(name("sourceFile"), solrHome + "/log4j-solr.properties"),
                            element(name("destinationFile"), outputDir + "/WEB-INF/classes/log4j.properties")
                    ),
                    execEnv
            );



            executeMojo(
                    plugin(
                            groupId("org.apache.maven.plugins"),
                            artifactId("maven-resources-plugin"),
                            version(MAVEN_RESOURCE_PLUGIN_VERSION)
                    ),
                    goal("copy-resources"),
                    configuration(
                            element(name("outputDirectory"), outputDir + "/WEB-INF/lib"),
                            element(name("resources"),
                                    element(name("resource"),
                                            element(name("directory"), solrHome + "/lib"),
                                            element(name("includes"),
                                                    element(name("include"), "*org.springframework*")
                                            ),
                                            element(name("filtering"), "false")
                                    )
                            )
                    ),
                    execEnv
            );



            ZipUtil.pack(outputDir, new File(solrHome + "/apache-solr-1.4.1.war"));


            // Install the Solr 1.0 war file in local maven  repo
            executeMojo(
@@ -621,6 +716,37 @@ public abstract class AbstractRunMojo extends AbstractMojo {
                ),
                execEnv
        );

        if (isPlatformVersionLtOrEqTo42() && enableSolr) {
            getLog().info("Platform is 4.2 and Solr is enabled, setting 'index.subsystem.name=solr' in alfresco-global.properties");

            executeMojo(
                    plugin(
                            groupId("com.google.code.maven-replacer-plugin"),
                            artifactId("replacer"),
                            version(MAVEN_REPLACER_PLUGIN_VERSION)
                    ),
                    goal("replace"),
                    configuration(
                            element(name("regex"), "false"),
                            element(name("includes"),
                                    element(name("include"), "${project.build.testOutputDirectory}/*.properties")
                            ),
                            element(name("replacements"),
                                    element(name("replacement"),
                                            element(name("token"), "index.subsystem.name=solr4"),
                                            element(name("value"), "index.subsystem.name=solr")
                                    ),
                                    element(name("replacement"),
                                            element(name("token"), "index.subsystem.name=lucene"),
                                            element(name("value"), "index.subsystem.name=solr")
                                    )
                            )
                    ),
                    execEnv
            );

        }
    }

    /**
@@ -1134,6 +1260,7 @@ public abstract class AbstractRunMojo extends AbstractMojo {
        tomcatPluginDependencies.add(
                // Packaging goes faster with this lib
                dependency("org.codehaus.plexus", "plexus-archiver", "2.3"));

        tomcatPluginDependencies.add(
                // The following dependency is needed, otherwise you get
                //  Caused by: java.lang.NoSuchMethodError:
@@ -1217,9 +1344,8 @@ public abstract class AbstractRunMojo extends AbstractMojo {

        // Set up the system properties that should be set for Tomcat
        ArrayList systemProps = new ArrayList<Element>();
        systemProps.add(element(name("java.io.tmpdir"), "${project.build.directory}/tmp"));
        if (enableSolr) {
            systemProps.add(element(name("solr.solr.home"), solrHome));
            systemProps.add(element(name("solr.solr.home"), solrHome + "/"));
        }
        if (enableActivitiApp) {
            // Should be in activiti-jar/src/test/resources
@@ -1275,6 +1401,7 @@ public abstract class AbstractRunMojo extends AbstractMojo {
                         */
                        element(name("useTestClasspath"), "true"),


                        /**
                         * Set up where Solr Home directory is
                         */
@@ -1472,6 +1599,11 @@ public abstract class AbstractRunMojo extends AbstractMojo {
     * @return
     */
    private void copyH2Dialect() throws MojoExecutionException {

        String h2SourceDir;

        if ( ! isPlatformVersionLtOrEqTo42()) {

            getLog().info("Unpacking DB Dialects and ibatis files from alfresco-repository artifact");
            executeMojo(
                    plugin(
@@ -1518,6 +1650,13 @@ public abstract class AbstractRunMojo extends AbstractMojo {
                );
            }

            h2SourceDir = project.getBuild().getTestOutputDirectory();
        } else {
            // 4.2 has the dbscript directly in the exploded WAR file so we simply grab them there
            h2SourceDir = getWarOutputDir(PLATFORM_WAR_PREFIX_NAME) + "/WEB-INF/classes";
        }


        getLog().info("Copying H2 Dialect SQL create files into target/test-classes");
        executeMojo(
                plugin(
@@ -1530,14 +1669,14 @@ public abstract class AbstractRunMojo extends AbstractMojo {
                        element(name("outputDirectory"), "${project.build.testOutputDirectory}"),
                        element(name("resources"),
                                element(name("resource"),
                                        element(name("directory"), "${project.build.testOutputDirectory}/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect"),
                                        element(name("directory"), h2SourceDir + "/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect"),
                                        element(name("includes"),
                                                element(name("include"), "*")
                                        ),
                                        element(name("targetPath"), "alfresco/dbscripts/create/org.hibernate.dialect.H2Dialect")
                                ),
                                element(name("resource"),
                                        element(name("directory"), "${project.build.testOutputDirectory}/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect"),
                                        element(name("directory"), h2SourceDir + "/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect"),
                                        element(name("includes"),
                                                element(name("include"), "*")
                                        ),