List of usage examples for com.liferay.portal.kernel.util PropsKeys RESOURCE_ACTIONS_READ_PORTLET_RESOURCES
String RESOURCE_ACTIONS_READ_PORTLET_RESOURCES
To view the source code for com.liferay.portal.kernel.util PropsKeys RESOURCE_ACTIONS_READ_PORTLET_RESOURCES.
Click Source Link
From source file:org.mimacom.maven.plugins.liferay.ServiceBuilderMojo.java
License:Apache License
protected void doExecute() throws Exception { File ignoreDir = new File(buildDir, "ignore"); String serviceFileName = "META-INF/service.xml"; File serviceFile = new File(resourcesDir, serviceFileName); boolean checkApi = false; boolean checkImpl = false; if (isServiceApiProject()) { checkApi = true;//from w w w .j a v a 2 s. co m setArtifactType(new File(buildDir, finalName + ".jar"), "jar"); } else { checkImpl = true; setArtifactType(artifactWarFile(), "war"); if (serviceFile.exists()) { log("found " + serviceFile.getAbsolutePath() + ", not looking for api dependency"); checkApi = true; } else { serviceFile = findServiceFile(serviceFileName); } } if (!serviceFile.exists()) { getLog().warn(serviceFile.getAbsolutePath() + " does not exist"); return; } getLog().info("Building from " + serviceFile.getAbsolutePath()); PropsUtil.set("spring.configs", "META-INF/service-builder-spring.xml"); PropsUtil.set(PropsKeys.RESOURCE_ACTIONS_READ_PORTLET_RESOURCES, "false"); InitUtil.initWithSpring(); File apiDir = new File(ignoreDir, "api"); File implDir = new File(ignoreDir, "impl"); File metaInfIgnore = new File(implDir, "META-INF"); File sqlDir = new File(implDir, "webapp/WEB-INF/sql"); if (!sqlDir.exists()) { getLog().info("creating sql dir"); sqlDir.mkdirs(); } tools.initLog(getLog()); tools.initLiferay(); tools.buildService(serviceFile.getAbsolutePath(), // new File(metaInfIgnore, "portlet-hbm.xml").getAbsolutePath(), // new File(metaInfIgnore, "portlet-orm.xml").getAbsolutePath(), new File(metaInfIgnore, "portlet-model-hints.xml").getAbsolutePath(), // new File(metaInfIgnore, "portlet-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "base-spring.xml").getAbsolutePath(), // null, // new File(metaInfIgnore, "dynamic-data-source-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "hibernate-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "infrastructure-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "shard-data-source-spring.xml").getAbsolutePath(), // apiDir.getAbsolutePath(), // implDir.getAbsolutePath(), // new File(implDir, "webapp/html/js/liferay/service.js").getAbsolutePath(), // null, // sqlDir.getAbsolutePath(), // "tables.sql", "indexes.sql", "indexes.properties", "sequences.sql", // autoNamespaceTables, beanLocatorUtil, propsUtil, pluginName, null); if (checkApi) { checkSources(apiDir, new File(buildDir, "generated-sources/api")); } if (checkImpl) { checkSources(implDir, new File(buildDir, "generated-sources/impl")); } if (!isServiceApiProject()) { String impl = "target/ignore/impl/"; log("copying from service.xml to WEB-INF"); copy(file(buildDir, "META-INF/service.xml"), todir(buildDir, finalName + "/WEB-INF")); log("setting build.number to " + buildNumber + " and copying service.properties from " + impl + " to " + outputDir); BufferedReader in = null; BufferedWriter out = null; try { in = new BufferedReader(new InputStreamReader( new FileInputStream(new File(implDir, "service.properties")), "ISO-8859-1")); out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(new File(outputDir, "service.properties")), "ISO-8859-1")); while (in.ready()) { String line = in.readLine(); line = line.replaceFirst("(build\\.number\\s*=\\s*)\\d+", "$1" + buildNumber); out.write(line); out.newLine(); } } finally { IOUtil.close(in); IOUtil.close(out); } log("copying from " + impl + "META-INF to " + outputDir + "/META-INF"); copyNonExistingFiles(ALL_FILES, new File(implDir, "META-INF"), new File(outputDir, "META-INF"), new File(resourcesDir, "META-INF")); log("copying from " + impl + "webapp to " + buildDir + "/" + finalName); copyNonExistingFiles(ALL_FILES, new File(implDir, "webapp"), new File(buildDir, finalName), new File(resourcesDir, "webapp")); } }
From source file:org.mimacom.maven.plugins.liferay.TwoArtifactsServiceBuilderMojo.java
License:Apache License
protected void doExecute() throws Exception { if (!apiSourceDir().exists()) { apiSourceDir().mkdirs();//from w w w . j av a2 s. co m } addSourceDir(apiSourceDir()); String serviceFileName = "META-INF/service.xml"; File serviceFile = new File(resourcesDir, serviceFileName); setArtifactType(new File(buildDir, finalName + ".war"), "war"); // mavenHelper.attachArtifact(project, "jar", new File(buildDir, finalName + "-api.jar")); if (!serviceFile.exists()) { getLog().warn(serviceFile.getAbsolutePath() + " does not exist"); return; } getLog().info("Building from " + serviceFile.getAbsolutePath()); PropsUtil.set("spring.configs", "META-INF/service-builder-spring.xml"); PropsUtil.set(PropsKeys.RESOURCE_ACTIONS_READ_PORTLET_RESOURCES, "false"); InitUtil.initWithSpring(); File ignoreDir = new File(buildDir, "liferay-generated"); File apiDir = new File(ignoreDir, "api"); File implDir = new File(ignoreDir, "impl"); File metaInfIgnore = new File(implDir, "META-INF"); File sqlDir = new File(implDir, "webapp/WEB-INF/sql"); if (!sqlDir.exists()) { getLog().info("creating sql dir"); sqlDir.mkdirs(); } log("Copying src/main/java to liferay-generated/impl"); copy(fileset(dir(sourceDir)), todir(implDir), overwrite(true)); log("Copying src/api/java to liferay-generated/api"); copy(fileset(dir(apiSourceDir())), todir(apiDir), overwrite(true)); tools.initLog(getLog()); tools.initLiferay(); tools.buildService(serviceFile.getAbsolutePath(), // new File(metaInfIgnore, "portlet-hbm.xml").getAbsolutePath(), // new File(metaInfIgnore, "portlet-orm.xml").getAbsolutePath(), new File(metaInfIgnore, "portlet-model-hints.xml").getAbsolutePath(), // new File(metaInfIgnore, "portlet-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "base-spring.xml").getAbsolutePath(), // null, // new File(metaInfIgnore, "dynamic-data-source-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "hibernate-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "infrastructure-spring.xml").getAbsolutePath(), // new File(metaInfIgnore, "shard-data-source-spring.xml").getAbsolutePath(), // apiDir.getAbsolutePath(), // implDir.getAbsolutePath(), // new File(implDir, "webapp/html/js/liferay/service.js").getAbsolutePath(), // null, // sqlDir.getAbsolutePath(), // "tables.sql", "indexes.sql", "indexes.properties", "sequences.sql", // autoNamespaceTables, beanLocatorUtil, propsUtil, pluginName, null); log("Moving not customized apis from liferay-generated/api to generated-sources/api"); File generatedApi = new File(buildDir, "generated-sources/api"); makeComplementary(JAVA_FILES, apiDir, apiSourceDir(), generatedApi); addSourceDir(generatedApi); log("Moving not customized impls from liferay-generated/impl to generated-sources/impl"); File generatedImpl = new File(buildDir, "generated-sources/impl"); makeComplementary(JAVA_FILES, implDir, sourceDir, generatedImpl); addSourceDir(generatedImpl); log("Moving not customized modifyable impls from generated-sources/impl to src/main/java"); move(fileset(dir(generatedImpl), includes("**/service/impl/*.java,**/model/impl/*.java"), excludes("**/*BaseImpl.java,**/*ModelImpl.java")), todir(sourceDir), overwrite(false)); log("copying service.xml to WEB-INF"); copy(file(resourcesDir, "META-INF/service.xml"), todir(buildDir, finalName + "/WEB-INF")); final String impl = "target/liferay-generated/impl/"; log("setting build.number to " + buildNumber + " and copying service.properties from " + impl + " to " + outputDir); outputDir.mkdirs(); BufferedReader in = null; BufferedWriter out = null; try { in = new BufferedReader(new InputStreamReader( new FileInputStream(new File(implDir, "service.properties")), "ISO-8859-1")); out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(new File(outputDir, "service.properties")), "ISO-8859-1")); while (in.ready()) { String line = in.readLine(); line = line.replaceFirst("(build\\.number\\s*=\\s*)\\d+", "$1" + buildNumber); out.write(line); out.newLine(); } } finally { IOUtil.close(in); IOUtil.close(out); } log("copying from " + impl + "META-INF to " + outputDir + "/META-INF"); copyNonExistingFiles(ALL_FILES, new File(implDir, "META-INF"), new File(outputDir, "META-INF"), new File(resourcesDir, "META-INF")); log("copying from " + impl + "webapp to " + buildDir + "/" + finalName); copyNonExistingFiles(ALL_FILES, new File(implDir, "webapp"), new File(buildDir, finalName), new File(resourcesDir, "webapp")); }