Katalon with external jar as dependency and not as a project resource? - jar

When using our Git based Katalon Studio project, we need to use an external jar.
According to the Katalon docs, as can be seen here, we need to paste the jar in our Drivers folder.
But the meaning of that is that we are pushing the jar into git, a pattern we don't really like (e.g. when new versions of the jar will be available, we can't simply use "latest")
From our Java projects we are customs to use dependencies in our projects/POM file, so the project's Git is not holding the dependencies jars.
Is there something similar in Katalon?

Imagination is key here. I simply used ant because why not . . .
Here is a dead simple build.xml, simply put at it at top level of your project.
<project name=app-tests" default="dist" basedir=".">
<description>
gets the dependencies
</description>
<!-- set global properties for this build -->
<property name="dist" location="Drivers"/>
<target name="install">
<mkdir dir="${dist}"/>
<!-- Joda Time -->
<get src="http://central.maven.org/maven2/joda-time/joda-time/2.10.1/joda-time-2.10.1.jar"
dest="${dist}"
verbose="true"
usetimestamp="true"/>
<!-- ibatis common -->
<get src="https://repository.liferay.com/nexus/content/repositories/public/org/apache/ibatis-
common/2.2.0/ibatis-common-2.2.0.jar"
dest="${dist}"
verbose="true"
usetimestamp="true"/>
<!-- json simple -->
<get src="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/json-simple/json-simple-1.1.1.jar"
dest="${dist}"
verbose="true"
usetimestamp="true"/>
</target>
</project>
Then run:
ant install
One could also do this with some bash action with curl or wget get kinda like so:
wget -P ./Drivers/ http://central.maven.org/maven2/joda-time/joda-time/2.10.1/joda-time-2.10.1.jar
Then pop a few of those into a build.sh and you're good to go.
Remember to restart Katalon for the the new items in the Drivers folder to take effect.
Enjoy!

My solution is: create a maven project under the same root-directory with katalon project, and add 'maven-dependency-plugin' plugin in the POM file,when run 'mvn clean packge', copy the target jar to the Drivers directory, and keep the jar in Drivers dir do not commit to git server.

Related

How to configure build for build undependent projects

I have a web project (asp.net) and I have several modules which should building in folder of the main project.
I can't find information about it.
I would like just build the main project and all modules should build too, but they not dependent with the main project.
Well, there still would be some dependency involved. You can use MsBuild task to build your projects along with main project. There are several options on how to include msbuild script to your solution, here is one of possible ways that allows to change the list of modules without reloading the MainProject and without adding dependencies to it.
Let's say we have MainProject and 2 modules: ClassLibrary1 and ClassLibrary2. Create a BuildModules.csproj file like this:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="BuildModules" ToolsVersion="4.0">
<ItemGroup>
<ModuleProject Include="ClassLibrary1\ClassLibrary1.csproj"></ModuleProject>
<ModuleProject Include="ClassLibrary3\ClassLibrary3.csproj"></ModuleProject>
</ItemGroup>
<Target Name="BuildModules">
<MSBuild Projects="#(ModuleProject)" Properties="OutputPath=..\MainProject\Bin\Debug;Configuration=Debug;" ContinueOnError="true">
</MSBuild>
</Target>
</Project>
Now this is a concept only, so I've hardcoded the path to bin\debug folder. ContinueOnError is true so in case some error occurs, it doesn't affect on MainProject build process. Put this file in your solution root folder.
Now in MainProject properties on Build Events tab add the following Pre-build command:
call C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe $(SolutionDir)BuildModules.csproj
The path to msbuild.exe may vary.
Now each time you build, it would rebuild your assemblies and you can easily change the list of modules in your BuildModules.csproj file.
UPDATE 1:
TFS not deploying all files. I guess this is because of our hardcoded paths to msbuild and etc. Try moving Pre-build command to MainProject.csproj file, in BeforeBuild target:
<Target Name="BeforeBuild">
<MSBuild Projects="..\BuildModules.csproj" Properties="Configuration=Debug"/>
</Target>
I'm not sure about the path though, but should be like this. And remove Pre-build command from build.

How to embed pom descriptors in a jar

When a jar is created using Maven. The META-INF directory in the jar contains sub-directory maven/group-id/artifact-id with pom.xml and pom.properties. How to do it with SBT?
Is there an option of a plugin that does that?
You can always publish 'maven style' with sbt - This will create the pom and pom.properties correctly.
To do this, you can use:
publishMavenStyle := true
And you will probably need to add the extra information required by the pom. To do this, set pomExtra:
pomExtra :=
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
For more information, see the docs: Publishing and the following describes in detail how to publish to a maven repo: Deploying to Sonatype.

Publish web package adding tasks to copy files

I have an ASP.NET web package deployment using Visual Studios 2012 in which I would like to copy off files before deployment and then copy them back once deployment is completed. These files happen to be under Content\upload. If I just deploy.cmd the files are deleted and so currently I need to copy them off manually and then copy them back once deployment is complete. I have tried several examples of similar situations for adding tasks to the Project file as well as extra files added to the project, such as:
Adding tasks inside targets I have created called Name="BeforePublish" Name="AfterPublish" in the Project file.
<Target Name="BeforePublish">
<Message Text="BeforePublish"/>
<Copy/>
</Target>
Adding file called ProjectName.wpp.targets and adding
<Project>
<Target Name="CopyMyFiles" BeforeTargets="BeforePublish">
<Message Text="CopyMyFiles called"/>
<Copy/>
</Target>
</Project>
Neither of these techniques seem to be called. Any other ideas? Where and how should I put these tasks?
You can actually solve this using a skip rule. Try calling your command file like this:
deploy.cmd -skip:objectName=dirPath,absolutePath=Content\\uploads$
For more information on the skip directive, see Web Deploy Operation Settings.

Specifying folders not to sync in Web Deploy

I use the following script to deploy my ASP.NET MVC app to our web server:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe MySolution.sln^
/p:Configuration=TeamCity-Test^
/p:OutputPath=bin^
/p:DeployOnBuild=True^
/p:DeployTarget=MSDeployPublish^
/p:MsDeployServiceUrl=https://mywebserver.com:8172/msdeploy.axd^
/p:username=MyDomain\MyUser^
/p:password=MyPassword^
/p:AllowUntrustedCertificate=True^
/p:DeployIisAppPath=mywebsitename.com^
/p:MSDeployPublishMethod=WMSVC
Now I need to specify to not sync the /uploads folder. Can I specify that in this script? Thanks!
Clarification:
I have the Uploads folder in my project. I'd like for Web Deploy to create the folder. I do not want it to delete the folder/subfolders/files from my web server because it contains user-uploaded content.
Clarification #2:
I just found the SkipExtraFilesOnServer=True option. However, I don't want this to be global. I'd like to set it to a single folder.
UPDATE:
Apparently, what you really want is prevent web deploy from removing existing directory on the destination server, but still have the folder created in case it's not there. You can accomplish this as follows:
create YourWebProjectName.wpp.targets file next to you the project file with the following content:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<MsDeploySkipRules Include="SkipELMAHFolderFiles">
<SkipAction></SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\NameOfYourFolder\\.*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipELMAHFolderChildFolders">
<SkipAction></SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\NameOfYourFolder\\.*\\*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
</ItemGroup>
</Project>
Change NameOfYourFolder and YourWebProjectName accordingly. This assumes, you have it in the root, I believe, you can use relative path if it's not the case.
The first MsDeploySkipRules entry tells webdeploy not to remove any files in Name_OfYourFolder.
The second MsDeploySkipRules tells webdeploy not to remove any child folders in Name_OfYourFolder.
Also, to have the folder created if it's not present on the destination server, you have to do the following:
include the folder into the project
add a dummy DeployemntPlaceholder.txt file into it and include it into the project as well
DeployemntPlaceholder.txt is required to tell MSBUild to add the folder into the package: empty folders are ignored.
I've tested this approach and it works fine when you run publish in the manner you've shown. I've used this answer to get the msbuild items syntaxt right. I believe, this is a MSBuild way to customize flags, passed to webdeploy by MSBuild Deployment Pipeline.
If you ran MSDeploy directly, you could use skip arguments in the following manner:
-skip:objectname='filePath',absolutepath='logs\\.*\\someNameToExclude\.txt'
UPDATE 2
You might also want to have ACL write permissions set on your \Uploads folder - there's a complete guide to do this: Setting Folder Permissions On Web Publish
Conserning the original question "Specifying folders not to sync in Web Deploy", the easiest way to do this is as follows:
You can create a publish profile and add the following lines:
<PropertyGroup>
<ExcludeFilesFromDeployment>
File1.aspx;File2.aspx
</ExcludeFilesFromDeployment>
<ExcludeFoldersFromDeployment>
Folder1;Folder2
</ExcludeFoldersFromDeployment>
</PropertyGroup>
I've tested this approach for excluding files using publish profiles. An easy guide is here (scroll to Edit the .pubxml file to exclude robots.txt section).
You can also do this in .wpp.targets file or edit you csproj. See more information at Web Deployment FAQ for Visual Studio and ASP.NET

How to execute an Ant task only when source files have been modified?

There must be an easy way to do this. I build a Flex app using ant that depends on a SWC library, which works fine except that it rebuilds the library whether it needs to or not. How do I tell ant to only run the task if any of the sources files of the library (*.as, *.mxml) are newer than the SWC?
I've looked at <dependset> but it only seems to delete files, not determine whether a task should be run or not. <depend> seems to expect a one-to-one relationship between the source and target files rather than a one-to-many relationship -- I have many input files and one output file, but no intermediate object files.
Thanks a lot,
Alex
You may use the Ant uptodate task to create a property, and execute your other target only if that property is set.
I don't know much about flex, but you probably want something like this:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="compile">
<target name="checkforchanges">
<uptodate property="nochanges">
<srcfiles dir="." includes="**/*.as"/>
<srcfiles dir="." includes="**/*.mxml"/>
<mapper to="applicaton.flex"/>
</uptodate>
</target>
<target name="compile" depends="checkforchanges" unless="nochanges">
...
</target>
</project>
The OutOfDate task from the ant contrib library is IMO much cleaner than the Ant uptodate option. The reason is that you have to define additional targets just to set the property.
The solution with Ant contrib (from their example page):
<outofdate>
<sourcefiles>
<pathelement path="build.xml"/>
<fileset dir="${lib.dir}"/>
</sourcefiles>
<targetfiles path="${jrun.file}"/>
<sequential>
<mkdir dir="${build.bin.dir}"/>
<echo file="${jrun.file}" message="java -cp ${jrun.path} $*"/>
<chmod file="${jrun.file}" perm="ugo+rx"/>
</sequential>
</outofdate>
Everything is kept nicely inside one single target.

Resources