Liferay 6.1 theme : jenkins and git - ant

I'm developing some liferay 6.1 themes using plugins sdk, and I want to do continuous integration using jenkins, I have a working jenkins servers with ant installed on it, also my theme project is synchronized with gitlab. The problem here is when I try to build the project using jenkins I have to following problem :
BUILD FAILED /home/settings/.jenkins/jobs/sample Basic
Theme/workspace/sample-theme-2-theme/build.xml:5: The following error
occurred while executing this line:
/home/settings/.jenkins/jobs/sample Basic
Theme/workspace/build-common-theme.xml:5: Cannot find
/home/settings/.jenkins/jobs/sample Basic
Theme/build-common-plugin.xml imported from
/home/settings/.jenkins/jobs/sample Basic
Theme/workspace/build-common-theme.xml
and here is my theme build.xml :
<project name="leyton-theme-2-theme" basedir="." default="deploy">
<import file="../build-common-theme.xml" />
<property name="theme.parent" value="classic" /> </project>
I know the project need the build-common-theme.xml which is located on his parent file theme, but I want only my theme project to be in git not the whole directory.

If you don't want to commit your entire Plugins SDK to git repository, then you should switch to using maven, because it will be more effort for you to make changes to build.xml files to make it working without the parent build.xml files.
Have a look at this very good blog post, and also detailed documentation on using Maven to develop Lifeary plugins.

Related

Sonarqube ANT build azure devops for SAP Hybris

I am trying do sonarqube setup for SAP hybris, we use azure devops for Build and uses ant build to SAP hybris.
sonarqube is located in a seperate server backed by SQL DB and i confirmed it's working.
I want the ant build to communicate to sonarqube server.
In config--> local.properties i added the following sonarqube properties
sonar.projectName=xxx_xxxxxx_xx
sonar.jdbc.url=jdbc:sqlserver://Rxxxxxxxx02:1433;databaseName=soxxrxxxx;integratedSecurity=true
sonar.projectKey=xxx_xxxxxx_xxKey
sonar.projectVersion=1.0
sonar.excludedExtensions=acceleratorcms,acceleratorfacades,acceleratorservices,acceleratorstorefrontcommons,addonsupport,captchaaddon,commercefacades,platformservices
for SonarQube > 6.4
sonar.host.url=http://xxxxxxbldxx:9000
sonar.login=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
can anyone help me on how set this up??
Have you tried Measuring Code Quality with Sonar to configure SAP Commerce Cloud with SonarQube?
Also, when you use sonar.host.url, you don't need sonar.jdbc.url anymore.
the reason is that the ANT task shipped with the Hybris distribution is not compatible with Sonar version 8. In order to solve your problem there are two options:
a) Local workaround
Delete the JAR sonarqube-ant-task-XXX.jar in your platform folder ./platform/resources/ant/sonar/lib. Download a newer version (e.g. sonarqube-ant-task-2.7.0.1612.jar) and place it in the folder ./platform/resources/ant/sonar/lib.
Edit the file ./platform/resources/ant/sonar/sonar.xml and change the element for defining the sonar task. You have to include the new jar file:
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath>
<path path="${platformhome}/resources/ant/sonar/lib/sonarqube-ant-task-2.7.0.1612.jar" />
</classpath>
</taskdef>
After applying this change, you should be able to run ant sonarcheck without the mentioned error.
b) CI-supported solution
If you want to automate your sonar check on a CI server (e.g. Jenkins), you have to override the sonar resources provided by the SAP platform distribution. A common way to do this is to use the customize approach:
create a customize folder in your config folder, e.g. ./hybris/config/customize
add the new jar and modified sonar.xml to this customize directory. So the structure will be:
./hybris/config/customize/platform/resources/ant/sonar/lib/sonarqube-ant-task-2.7.0.1612.jar
./hybris/config/customize/platform/resources/ant/sonar/sonar.xml
In your build job you have to ensure that you invoke this step:
ant customize
This target will override the resources in the platform distribution. It is the offial way stated by SAP to handle such customizations.
After you invoked the ant customize target on your build server, you can build the platform (ant clean all) and invoke the sonar check (ant sonarcheck).

How to build solr.tgz file from source using "ant package"

I want to build a .tgz distribution file from solr.
The build.xml file tells me to use "ant package".
However, running ant package gets everything from svn and builds ./package/solr-6.0.0-SNAPSHOT.zip whereas my code base is from lucene_4_10_x branch.
How do I build ./package/solr-4.10.3.zip from the source code?
I need to build from the source code because I have some local changes that I want to compile and deploy.
According to LUCENE-4288, Solr will only package properly if it's checked out from SVN by default. However, if you change package-src-tgz to package-local-src-tgz, it will properly package. Find the following lines in solr/build.xml:
<!-- make a distribution -->
<target name="package" depends="package-src-tgz,..."/>
And change package-src-tgz to package-local-src-tgz.
<!-- make a distribution -->
<target name="package" depends="package-local-src-tgz,..."/>
Then just rerun ant package inside solr/, and the packaged archives (solr-<version>-SNAPSHOT.tgz and solr-<version>-SNAPSHOT.zip) will be available under solr/package/.

In Ivy what does impossible to publish artifacts FileNotFoundException Error Mean?

I'm working within a large build system that uses Ant/Ivy. I try to use a predefined ant task that uses ivy:publish ant task and get this error:
impossible to publish artifacts for com.company.project1.proj1#MySupportJar;working#server1: java.io.FileNotFoundException: /path_to/ivy-repository/com.company.project1.proj1/MySupportJar/5.1.3.part/MySupportJar-5.1.3.jar (No such file or directory)
The directory in the error message exists up to the version number part (5.1.3.part).
I am new to Ivy but think I get the basics of how it works. I can not find much on the exact meaning of this error so if someone could help or point me to an explanation I think I could resolve the issue from there.
Ant target
<target name="publish-shared" depends="ivyInit, resolve"
description="Publish to the shared repository">
<ivy:publish pubrevision="5.1.3"
resolver="shared"
pubdate="${timestamp}"
forcedeliver="true"
update="true"
conf="distro, docs">
<artifacts pattern="dist/[artifact].[ext]"/>
</ivy:publish>
</target>
Ivy file snippet
<publications>
<artifact name="MySupportJar" type="jar" conf="distro" />
<artifact name="MySupportJar-source" type="source" ext="jar" conf="docs" />
</publications>
Thanks.
Thanks for all the suggestions. Turns out to be a simple solution that I was not looking for.
The problem was permissions at /path_to/ivy-repository/com.company.project1. I did not have write permission. The .part file is a temporary file written by Ivy. Ivy could not write the temporary file so when it got to reading the file it failed to find it.
I'm answering this so that it might help someone later.
Thanks.
I'm fairly new to Ant with Ivy too. What I've done is combine a local Maven repository (Artifactory), with Jenkins as a continuous integration server. When we build a jar, I also produce the Maven pom.xml with it. Then, I use the mvn deploy:file command to deploy the desired build to our Maven repository.
The developer manually deploys the jar to our Maven repository via the Promoted Build plugin to Jenkins. The developer selects the build to deploy to Maven, and then pretty much presses a button, and that build will be deployed.
I actually produce two pomswith each build. One ispom.xmland the other ispom-snapshot.xml`. We deploy the snapshot with each build, so other developers can use the latest jar instead of the officially deployed one. I've put the whole thing in github if you're interested.
The only decent Ant/Ivy documentation I've seen is Manning's Ant in Action by Steve Loughram. If it wasn't for that, I probably would have never even tried Ant with Ivy. The online Ant/Ivy documentation at Apache is just plain awful.
I've looked over what you have. I suspect it might be an issue with your ivy-settings.xml file. Somewhere, it's getting the part string as the valid location for publishing the file. Otherwise, I have no idea.
As I said, we use a Maven repository for our site repository, and then use Maven to actually deploy the jars to the repository. I simply found that much easier to do it that way than to figure out how to do this in pure Ivy. Besides, it also means that our Maven projects can also use the jars from our Ant/Ivy projects.

How to Open an Ant project (Nutch Source) at Intellij Idea?

I want to open Nutch 2.1 source file (http://www.eu.apache.org/dist/nutch/2.1/) at Intellij IDEA. Here is an explanation of how to open it at Eclipse: http://wiki.apache.org/nutch/RunNutchInEclipse
However I am not familiar with Ant (I use Maven) and when I open that source file many classes are not known by Intellij.
i.e.:
org.apache.hadoop.mapreduce.JobContext
org.apache.gora.mapreduce.GoraMapper
How can I add them to library or what should I do?
I finally figure out how to do it. Now our team can dev nutch in IntellIJ
The process we do
Get nutch source from apache.org
wget http://www.eu.apache.org/dist/nutch/2.3/apache-nutch-2.3-src.tar.gz
Import nutch source in intellij
Get Dependencies by Ant
Run ant runtime
Run ant test
Import dependencies into Intellij
File > Project Structures
Library > Ivy
Click to Plus button
Select all libraries in apache-nutch-2.3/build/lib
Now we have a project with nutch source and all dependencies
I think, you should use ant build for nutch project. Because, pom.xml is problematical for nutch. If you want to use it anyway maven, you check maven dependency in pom.xml .
I think, the problem can be solved with the following:
You create new project via idea and add nutch source. Idea is not
supported ivy ant project. You can install ivy plugin for idea, I
suppose, Idea12 does not support it.
or
You can create ant project for nutch via eclipse and then save
project. Then open the project on idea via eclipse classpath.
or
You can configure classpath. If you use ant build, you should add jars : File->ProjectStructure as follows:
Create a library
Attach Files
Then, if you use ant build, select jars from NUTCH_HOME/build/lib/* after build.
If you use maven build, select jars from ~/.m2/* (MAVEN_REPO)
Although Intellij supports running ant scripts directly through the IDE via the ant plugin, the Intellij editor will not figure out the classpath using your build.xml file by itself.This will result in the editor showing the code littered with errors.
Unfortunately the only solution I found to this is to add all the jars manually.You can get all the jars needed by building the ant project using the ant jar command.
So these are the steps you need to follow :->
1.Run ant jar command in the root of your program
2.Copy all the jars created inside the build folder(they will not be directly inside build folder.I had to go from build->ivy->lib->{project name})
3.Paste these jars to a new folder created somewhere outside the directory
4.Go to File->Project Structure->Libraries. Press the + button.
5.Select all the copied jars and press ok to any prompts which appear.
6.Press finish and wait for indexing to complete.Any dependency errors in the editor should resolve now.
Note: Since you are manually adding jars, you would need to keep them in sync if you change your build.xml file for any dependency change.
It seems that dependencies are managed using Ivy (see the ivy folder in the sources archives), so you could try to install the Ivy plugin, which would allow you to fix your classpath issues.

Do I have to use a solution file with a Team Build definition?

Our application uses a combination of ASP.NET and Flex platforms.
I am able to successfully use the build service to build and deploy the .NET web site. That works fine. However, we also have our ActionScript files in TFS and I've created a batch file to successfully compile the ActionScript from the command-line.
I want to create two separate build definitions for the ASP.NET and Flex compilation. Flex obviously doesn't have an SLN file--can I create a build definition file from scratch to support the Flex compile batch file without a solution file? The tasks are fairly simple to create (see below), but I've never built a customized Team Build script without using the Create wizard--and the Create wizard expects you to supply a solution file, which I don't have.
My build script would be very straight-forward:
Get the latest version of the ActionScript files
Run the ActionScript compile batch file
Copy the ActionScript files to the deploy folder
Absolutely. TFSBuild.proj is an MSBuild file that calls your solution build in TFS. You can modify that to build whatever you want using MSBuild, which is the language which .vbproj and .csproj files are written in. There's a wealth of tasks that MSBuild allows you to use...
No you don't need a solution file in getting a build done using TFSBuild. A very simple project file could look like this (courtesy Aaron Hallberg):
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<Target Name="EndToEndIteration">
<Exec Command="SomeScript.cmd" />
</Target>
</Project>
Please investigate this page from Aarons blog. The default targets in a tfsbuild.proj file is actually defined in a "common" targets file and imported into the projfile by this instruction:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
If the import is removed you only need the EndToEndIteration target to get tfsbuild running....
All the best
/Niels

Resources