//How to Write below code in gradle
converting from ant to gradle
<property name="abc" value="path/to/abc/file"/>
<property name="pqr" value="path/to/pqr/file"/>
<property name="xyz" value="path/to/xyz/file"/>
<var name="myfiltersetTokens" value="abc,pqr,xyz"/>
<for list="${myfiltersetTokens}" param="prop" >
<sequential>
<propertyregex property="#{prop}" input="${#{prop}}" override ="yes" regexp="^[ \s]+|[ \s]+$" replace="" global="true" />
</sequential>
</for>
If you want to copy & transform you can use Copy.filter
Eg:
task copyAndTransform(type: Copy) {
from 'path/to/abc/file'
from 'path/to/pqr/file'
from 'path/to/xyz/file'
into 'someDir'
filter { it.replaceAll('^[ \s]+|[ \s]+$', '') }
}
Related
Create a json webservice for liferay with:
mvn -X archetype:generate -DarchetypeGroupId=com.liferay -DarchetypeArtifactId=com.liferay.project.templates.service.builder -DarchetypeVersion=1.0.7 -DgroupId=com.paygroup -DartifactId=com.paygroup.liferay.templates.service -DinteractiveMode=false -Dauthor=Author
As a result I got two projects one is an "api" and another is a "service".
The service application has a configuration file (service.xml) that leaves it this way:
<service-builder package-path="com.paygroup.liferay.service">
<namespace>Empresas</namespace>
<entity local-service="true" name="Empresas" remote-service="true" uuid="true">
<column name="empresaName" primary="true" type="String" />
<column name="empresaId" type="long" />
<column name="convenio1" type="String" />
<column name="convenio2" type="String" />
<column name="convenio3" type="String" />
<column name="descripcion" type="String" />
<column name="activo" type="boolean" />
<column name="fecha" type="Date" />
<order by="asc">
<order-column name="empresaId" />
</order>
<finder name="EmpresaName" return-type="Collection">
<finder-column name="empresaName" />
</finder>
<reference entity="AssetEntry" package-path="com.liferay.portlet.asset" />
<reference entity="AssetTag" package-path="com.liferay.portlet.asset" />
</entity>
</service-builder>
Running the service-builder command (mvn service-builder:build) works great but when packaging the project with mvn package there is a long list of class errors that are not found:
[ERROR] /media/media/git/GITLAB/demos/liferay/ejemplo-json-webservice/json-webservice/json-webservice-service/src/main/java/com/paygroup/liferay/service/service/persistence/impl/EmpresasPersistenceImpl.java:[38,46]
package com.paygroup.liferay.service.exception does not exist
[ERROR] /media/media/git/GITLAB/demos/liferay/ejemplo-json-webservice/json-webservice/json-webservice-service/src/main/java/com/paygroup/liferay/service/service/persistence/impl/EmpresasPersistenceImpl.java:[39,42], cannot find symbol
[ERROR] symbol: class Empresas
[ERROR] location: package com.paygroup.liferay.service.model
Why does not the service-builder create these classes?
will the service.xml be misconfigured?
you need to run mvn clean install on parent project.
ex: project name abc. So, you'll get abc-service, abc-api after creating service project. you need to run your command on abc project
I have integrated enunciate framework to generate the API document for the Spring RESTful project. I have followed the steps from https://github.com/stoicflame/enunciate/wiki/Executables and deployed the war created from the enunciate configuration in the tomcat server(http://localhost:8080/sample_enunciate) but its displaying the empty document. Here I have provided the configuration details used in the sample project.
NOTE: But the similar configuration is working with Jersey restful project. I really stuck here. Please let me know, is this bug with the enunciate framework integration with Spring project. Thanks in advance.
Project configuration:
java -1.7.0
tomcat -6.0 &7.0
ant -1.9.4
spring -4.0.5
enunciate -1.30
jars:
enunciate-core-1.30-RC1.jar
enunciate-core-annotations-1.30-RC1.j
enunciate-core-rt-1.30-RC1.jar
enunciate-java-client-1.30-RC1.jar
enunciate-docs-1.30-RC1.jar
enunciate-rt-1.30-RC1.jar
enunciate-spring-app-rt-1.30-RC1.jar
enunciate-spring-jaxws-rt-1.30-RC1.ja
spring-aop-4.0.5.RELEASE.jar
spring-beans-4.0.5.RELEASE.jar
spring-context-4.0.5.RELEASE.jar
spring-context-support-2.5.4.jar
spring-core-4.0.5.RELEASE.jar
spring-expression-4.0.5.RELEASE.jar
spring-jdbc-4.0.5.RELEASE.jar
spring-test-4.0.5.RELEASE.jar
spring-tx-4.0.5.RELEASE.jar
spring-web-4.0.5.RELEASE.jar
spring-webmvc-4.0.5.RELEASE.jar
This is my enunciate.xml.
enunciate.xml
<?xml version="1.0"?>
<api-classes>
<include pattern="com.sample.controller.*" />
</api-classes>
<modules>
<!-- Docs -->
<docs title="example" copyright="Example.com"/>
<webapp mergeWebXML="WebContent/WEB-INF/web.xml" />
<spring-app disabled="false" springVersion="4.0.5">
<springImport file="resources/dev/applicationContext.xml" />
<springImport file="WebContent/WEB-INF/rest-servlet.xml" />
</spring-app>
<c disabled="true" />
<csharp disabled="true" />
<java-client disabled="false" />
<cxf disabled="false" />
<gwt disabled="false" />
<jaxws-client disabled="true" />
<jaxws-ri disabled="true" />
<jaxws-support disabled="true" />
<jersey disabled="true" />
<xml disabled="false" />
<obj-c disabled="true" />
<rest disabled="false" />
</modules>
properties file for build.xml
enunciate_build.properties
JAVA_HOME=C:/Java/jdk1.7.0/
tomcat.home=D:/xampp/tomcat
This is my build.xml
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project default = "enunciate">
<property file ="enunciate_build.properties"/>
<property name="lib.dir" value="../libs" />
<property name="src.dir" value="src"/>
<target name = "enunciate">
<path id= "enunciate.classpath">
<fileset dir = "${lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir ="${lib.dir}/modules/spring">
<include name="*.jar"/>
</fileset>
<fileset dir = "${JAVA_HOME}">
<include name = "lib/tools.jar"/>
</fileset>
</path>
<taskdef name="enunciate" classname = "org.codehaus.enunciate.main.EnunciateTask">
<classpath refid = "enunciate.classpath"/>
</taskdef>
<enunciate javacSourceVersion="1.7" javacTargetVersion="1.7" basedir = "${src.dir}" configFile="enunciate.xml">
<include name = "**/*.java"/>
<classpath refid= "enunciate.classpath"/>
<export artifactId="war.file" destination="${tomcat.home}/webapps/sample_enunciate.war"/>
</enunciate>
</target>
</project>
Enunciate only recognizes JAX-RS annotations right now. For further information follow this link.https://github.com/stoicflame/enunciate/issues/60
I have configured sonar in my build xml as shown below but upon execution of my build.xml i am getting the error below..can u plas advise how to overcome from this error
target name="sonar">
<echo message="**** thirdparty.lib.dir -- > ${thirdparty.lib.dir}/sonar ****"/>
<sonar:sonar workDir="${build.dir}" key="gtr_61.all.rules:dev" version="1.0" xmlns:sonar="antlib:org.sonar.ant">
<!-- source directories (required) -->
<sources>
<path location="${pps.dir}/src" />
<path location="${pn.dir}/src" />
</sources>
<property key="sonar.host.url" value="https://abc/" />
<property key="sonar.jdbc.url" value="jdbc:oracle:thin:abc" />
<property key="sonar.jdbc.driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property key="sonar.jdbc.username" value="=AAA" />
<property key="sonar.jdbc.password" value="BBB" />
<property name="sonar.scm.url" value="https://svn.ats" />
<property name="sonar.java.source" value="1.5" />
<property name="sonar.language" value="java"/>
<property name="sonar.projectVersion" value="1.0"/>
<tstamp prefix="build-info">
<format property="current-date" pattern="dd-MMM-yyyy" locale="en" />
<format property="current-time" pattern="HH:mm:ss z" locale="en" />
<format property="year-month-day" pattern="yyyy-MM-dd" locale="en" />
</tstamp>
<!-- cobertura -->
<property key="sonar.cobertura.reportPath" value="cobertura-report/coverage.xml" />
<property key="sonar.dynamicAnalysis" value="reuseReports" />
<!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
<binaries>
<path location="${ps.dir}/build/classes" />
<path location="${omm.dir}/build/classes" />
</binaries>
<!-- path to libraries (optional). These libraries are for example used by the Java Findbugs plugin -->
<libraries>
<path location="${lib.dir}" />
</libraries>
<property key="sonar.profile" value="abc Rule" />
<!--property key="sonar.profile" value="Custom Rules" -->
</sonar:sonar>
the error i am getting is ..
onar
[06:56:15]echo
[06:56:15]**** thirdparty.lib.dir -- > /opt/app//buildAgent-8.0.3/work/pla/lib/thirdparty/sonar ****
[06:56:15]sonar:sonar
[06:56:15]property doesn't support the "name" attribute
If my feeling is correct you're using a very old version of the SonarQube Ant task. Here is the way to configure this SonarQube Ant task: http://docs.codehaus.org/display/SONAR/Analyzing+with+SonarQube+Ant+Task
Here is a latest documentation on the new syntax:
http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Ant+Task
I wish to break a string in wso2esb using xpath
my input like this
<property name="Message" value="assetname:ups,assetcode:452chi,assetid:548935,assetvalue:215" scope="default"/>
i need break in same property using xpath
i need like this
assetname:ups
assetcode=452chi
assetid=54895
assetvalue=215
for this i tried with tokenize function but wso2esb showing errors
my configure file
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Xpathcheck" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="max" value="1" scope="default" type="STRING"/>
<property name="min" value="1" scope="default" type="STRING"/>
<property name="MessageText" expression="fn:concat('Assetid:',get-property('min'),',','Assetname:',get-property('max'))" scope="default" type="STRING"/>
<property name="Tokenize" expression="fn:tokenize(get-property('Messagetext'),',')" scope="default" type="STRING"/>
<log>
<property name="MessageText" expression="get-property('MessageText')"/>
<property name="Tokenize" expression="get-property('Tokenize')"/>
</log>
</inSequence>
<outSequence/>
</target>
<description></description>
</proxy>
But its throwing errors like this u have any idea for this i need store this in Db table as a one field which look like separate lines
error is
ERROR - SynapseXPath Evaluation of the XPath expression fn:tokenize(get-property('Messagetext'),',') resulted in an error
org.jaxen.UnresolvableException: No Such Function tokenize
tokenize is a function comes with XPath 2.0. To enable XPath 2.0 functions uncomment the following entry in the synapse.properties file which is located at $ESB_HOME/repository/conf directory
synapse.xpath.dom.failover.enabled=true
then you have to specify the mediator as follows,
<property name="Message" value="a,b,c,d,e" scope="default"/>
<property xmlns:fn="http://www.w3.org/2005/xpath-functions" name="Tokenize" expression="fn:tokenize(syn:get-property('Message'),',')" scope="default" type="STRING"/>
I dont think this can be done through XPath, XPath is to navigate elements in an XML. You can do this by using a script mediator and write a JS to break the property values.
use the following to access the ESB params from the script mediator
<script language="js"> var test_param = mc.getProperty('Message')
Use the following to retrieve the params within the script mediator back to the ESB
mc.setProperty("param1",var1)
mc.setProperty("param2",var2)
Use the javascript to carry out the required string manupulations
When i run junit test cases, getting following error:
Invalid bean definition with name 'CacheRegionManagerFactory' defined in class path resource [com/bgc/ecm/core/caching/cacheRegionManager-ctx.xml]: Could not resolve placeholder 'appRoot'
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'CacheRegionManagerFactory' defined in class path resource [com/bgc/ecm/core/caching/cacheRegionManager-ctx.xml]: Could not resolve placeholder 'appRoot'
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:268)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
cacheRegionManager-ctx.xml file:
<bean id="CacheRegionManagerFactory" class="com.bgc.ecm.core.caching.CacheRegionManagerFactory">
<property name="diskStoreCachePath" value="${diskStoreCacheRootPath}/${appRoot}/was/var/elnino/${appName}/${cloneNumber}"/>
<property name="defaultRegion" ref="DefaultRegion"/>
<property name="regionInfos" ref="CustomRegions"/>
</bean>
propertyContext.xml:
<context:property-placeholder
location="classpath:/property/globalContext.properties,
classpath:/property/globalContext-${app.env}.properties,
classpath:/property/globalContext-${app.env}-${app.module}.properties,
classpath:/property/applicationContext.properties,
classpath:/property/applicationContext-${app.module}.properties,
classpath:/property/applicationContext-${app.env}.properties,
classpath:/property/applicationContext-${app.env}-${app.module}.properties"/>
and applicationContext-DEV-FNT.properties contains:
appName=bgc-elnino-core-cluster
appRoot=ecm
cloneNumber=1
site=elnino-core
Junit target:
<target name="junit" depends="init-junit">
<copy todir="${TEST_BUILD_DIR}/" overwrite="true">
<fileset dir="${COMP_TESTCONFIG_DIR}">
<exclude name="*.properties.template" />
</fileset>
</copy>
<junit printsummary="on" fork="yes" forkmode="perBatch" haltonfailure="false" failureproperty="junit.failure" showoutput="false">
<classpath>
<path refid="CLASSPATH_JUNIT"/>
</classpath>
<batchtest fork="no" todir="${TEST_BUILD_DIR}">
<fileset dir="${COMP_TEST_SRC}" erroronmissingdir="false">
<include name="**/*Test.java" />
<include name="**/Test*.java" />
</fileset>
</batchtest>
<formatter type="xml" />
</junit>
<junitreport todir="${JUNIT_REPORT}">
<fileset dir="${TEST_BUILD_DIR}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${JUNIT_REPORT}"/>
</junitreport>
<delete dir="${TEST_BUILD_DIR}" />
</target>
env variable is:
public final void setupEnvironmentPropertiesIfNeeded()
{
String address = (new StringBuilder()).append("#").append(Integer.toHexString(System.identityHashCode(this))).toString();
if(StringUtils.isEmpty(System.getProperty("app.env")))
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.env will be set to DEV").toString());
System.setProperty("app.env", "DEV");
} else
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.env already set to:'").append(System.getProperty("app.env")).append("'").toString());
}
if(StringUtils.isEmpty(System.getProperty("app.module")))
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.module will be set to FNT").toString());
System.setProperty("app.module", "FNT");
} else
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.module already set to:'").append(System.getProperty("app.module")).append("'").toString());
}
}
It appears that your properties file is not getting loaded. Try explicitly loading the properties file using:
<property file="applicationContext-DEV-FNT.properties" />
issue can be solved by passing "-DappRoot=ECM" parameter and other required parameters.