Close the loop on 4.2 support and Solr

This commit is contained in:
Ole Hejlskov
2017-03-22 21:07:17 +01:00
parent 3630cced6d
commit 245a51402d
3 changed files with 167 additions and 30 deletions
@@ -73,7 +73,6 @@
<atomic>true</atomic> <atomic>true</atomic>
<stored>false</stored> <stored>false</stored>
<tokenised>false</tokenised> <tokenised>false</tokenised>
<facetable>true</facetable>
</index> </index>
<constraints> <constraints>
<constraint ref="acme:securityClassificationOptions"/> <constraint ref="acme:securityClassificationOptions"/>
@@ -73,7 +73,6 @@
<atomic>true</atomic> <atomic>true</atomic>
<stored>false</stored> <stored>false</stored>
<tokenised>false</tokenised> <tokenised>false</tokenised>
<facetable>true</facetable>
</index> </index>
<constraints> <constraints>
<constraint ref="acme:securityClassificationOptions"/> <constraint ref="acme:securityClassificationOptions"/>
@@ -475,9 +475,17 @@ public abstract class AbstractRunMojo extends AbstractMojo {
element(name("token"), "@@ALFRESCO_SOLR4_DATA_DIR@@"), element(name("token"), "@@ALFRESCO_SOLR4_DATA_DIR@@"),
element(name("value"), "${solrDataDir}/index") element(name("value"), "${solrDataDir}/index")
), ),
element(name("replacement"),
element(name("token"), "@@ALFRESCO_SOLR_DIR@@"),
element(name("value"), "${solrDataDir}/index")
),
element(name("replacement"), element(name("replacement"),
element(name("token"), "alfresco.port=8080"), element(name("token"), "alfresco.port=8080"),
element(name("value"), "alfresco.port=" + getPort()) 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 { protected void installSolr10InLocalRepo() throws MojoExecutionException {
if (isPlatformVersionLtOrEqTo42()) { if (isPlatformVersionLtOrEqTo42()) {
getLog().info("Installing Solr 1.0 WAR in local Maven repo"); 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 // Install the Solr 1.0 war file in local maven repo
executeMojo( executeMojo(
@@ -621,6 +716,37 @@ public abstract class AbstractRunMojo extends AbstractMojo {
), ),
execEnv 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( tomcatPluginDependencies.add(
// Packaging goes faster with this lib // Packaging goes faster with this lib
dependency("org.codehaus.plexus", "plexus-archiver", "2.3")); dependency("org.codehaus.plexus", "plexus-archiver", "2.3"));
tomcatPluginDependencies.add( tomcatPluginDependencies.add(
// The following dependency is needed, otherwise you get // The following dependency is needed, otherwise you get
// Caused by: java.lang.NoSuchMethodError: // 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 // Set up the system properties that should be set for Tomcat
ArrayList systemProps = new ArrayList<Element>(); ArrayList systemProps = new ArrayList<Element>();
systemProps.add(element(name("java.io.tmpdir"), "${project.build.directory}/tmp"));
if (enableSolr) { if (enableSolr) {
systemProps.add(element(name("solr.solr.home"), solrHome)); systemProps.add(element(name("solr.solr.home"), solrHome + "/"));
} }
if (enableActivitiApp) { if (enableActivitiApp) {
// Should be in activiti-jar/src/test/resources // Should be in activiti-jar/src/test/resources
@@ -1275,6 +1401,7 @@ public abstract class AbstractRunMojo extends AbstractMojo {
*/ */
element(name("useTestClasspath"), "true"), element(name("useTestClasspath"), "true"),
/** /**
* Set up where Solr Home directory is * Set up where Solr Home directory is
*/ */
@@ -1472,30 +1599,12 @@ public abstract class AbstractRunMojo extends AbstractMojo {
* @return * @return
*/ */
private void copyH2Dialect() throws MojoExecutionException { private void copyH2Dialect() throws MojoExecutionException {
getLog().info("Unpacking DB Dialects and ibatis files from alfresco-repository artifact");
executeMojo(
plugin(
groupId("org.apache.maven.plugins"),
artifactId("maven-dependency-plugin"),
version(MAVEN_DEPENDENCY_PLUGIN_VERSION)
),
goal("unpack"),
configuration(
element(name("outputDirectory"), "${project.build.testOutputDirectory}"),
element(name("artifactItems"),
element(name("artifactItem"),
element(name("groupId"), alfrescoGroupId),
element(name("artifactId"), "alfresco-repository"),
element(name("version"), alfrescoPlatformVersion),
element(name("includes"), "alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/dbscripts/upgrade/*/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/*")
)
)
),
execEnv
);
// If we're in enterprise we need to make sure we grab everything String h2SourceDir;
if (this.alfrescoEdition.equals(ALFRESCO_ENTERPRISE_EDITION)) {
if ( ! isPlatformVersionLtOrEqTo42()) {
getLog().info("Unpacking DB Dialects and ibatis files from alfresco-repository artifact");
executeMojo( executeMojo(
plugin( plugin(
groupId("org.apache.maven.plugins"), groupId("org.apache.maven.plugins"),
@@ -1508,7 +1617,7 @@ public abstract class AbstractRunMojo extends AbstractMojo {
element(name("artifactItems"), element(name("artifactItems"),
element(name("artifactItem"), element(name("artifactItem"),
element(name("groupId"), alfrescoGroupId), element(name("groupId"), alfrescoGroupId),
element(name("artifactId"), "alfresco-enterprise-repository"), element(name("artifactId"), "alfresco-repository"),
element(name("version"), alfrescoPlatformVersion), element(name("version"), alfrescoPlatformVersion),
element(name("includes"), "alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/dbscripts/upgrade/*/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/*") element(name("includes"), "alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/dbscripts/upgrade/*/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/*")
) )
@@ -1516,8 +1625,38 @@ public abstract class AbstractRunMojo extends AbstractMojo {
), ),
execEnv execEnv
); );
// If we're in enterprise we need to make sure we grab everything
if (this.alfrescoEdition.equals(ALFRESCO_ENTERPRISE_EDITION)) {
executeMojo(
plugin(
groupId("org.apache.maven.plugins"),
artifactId("maven-dependency-plugin"),
version(MAVEN_DEPENDENCY_PLUGIN_VERSION)
),
goal("unpack"),
configuration(
element(name("outputDirectory"), "${project.build.testOutputDirectory}"),
element(name("artifactItems"),
element(name("artifactItem"),
element(name("groupId"), alfrescoGroupId),
element(name("artifactId"), "alfresco-enterprise-repository"),
element(name("version"), alfrescoPlatformVersion),
element(name("includes"), "alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/dbscripts/upgrade/*/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/*")
)
)
),
execEnv
);
}
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"); getLog().info("Copying H2 Dialect SQL create files into target/test-classes");
executeMojo( executeMojo(
plugin( plugin(
@@ -1530,14 +1669,14 @@ public abstract class AbstractRunMojo extends AbstractMojo {
element(name("outputDirectory"), "${project.build.testOutputDirectory}"), element(name("outputDirectory"), "${project.build.testOutputDirectory}"),
element(name("resources"), element(name("resources"),
element(name("resource"), 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("includes"),
element(name("include"), "*") element(name("include"), "*")
), ),
element(name("targetPath"), "alfresco/dbscripts/create/org.hibernate.dialect.H2Dialect") element(name("targetPath"), "alfresco/dbscripts/create/org.hibernate.dialect.H2Dialect")
), ),
element(name("resource"), 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("includes"),
element(name("include"), "*") element(name("include"), "*")
), ),