How to config jrebel in Hybris backoffice extensions? - sap-commerce-cloud

After I created one backoffice extension using "ant extgen with ybackoffice template".
And I want add jrebel to this backoffice extensions but not reloading when i change code.
So, please help me to solve the problem to save time for deployment.Thanks

Check if backoffice extensions packaged as .jar packages contain rebel.xml files and if you make a code change in .java file, new .class files are generated in $PLATFORM_HOME/bin/custom/$EXTENSION_NAME/backoffice/classes directory that is defined in rebel.xml.
copy-paste from documentation portal:
Backoffice extensions that are packaged as JAR files need a descriptor file called rebel.xml. This XML file will tell JRebel that the .class files for this JAR are in that folder. To achieve this, you will need to do the following for all extensions you want reloaded:
To recompile via an IDE, set the compile output to where the classes are actually compiled to with ant build. For backoffice extensions, this would be $PLATFORM_HOME/bin/custom/$EXTENSION_NAME/backoffice/classes.
Create the following rebel.xml in $EXTENSION_NAME/backoffice/resources:
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">
<classpath>
<!-- Make sure to replace $PLATFORM_HOME and $EXTENSION_NAME with your concrete values -->
<dir name="$PLATFORM_HOME/bin/custom/$EXTENSION_NAME/backoffice/classes"/>
</classpath>
</application>
Edit $EXTENSION_NAME/buildcallbacks.xml and add the following before build callback:
<macrodef name="$EXTENSION_NAME_before_build">
<sequential>
<mkdir dir="${ext.$EXTENSION_NAME.path}/backoffice/classes" />
<copy file="${ext.$EXTENSION_NAME.path}/backoffice/resources/rebel.xml" todir="${ext.$EXTENSION_NAME.path}/backoffice/classes/" failonerror="false" />
</sequential>
</macrodef>
This will make sure that rebel.xml is bundled into the compiled extension JAR file on build.
When changing classes from the IDE, just recompile the class (either with ant build or via the IDE after setting the correct compile output) and reload the browser. The changed .class files are picked up by JRebel and reloaded on the fly.

Related

How can I import a .props file that gets generated by a Target?

Background
I am attempting to build a C++ Visual Studio project. My project is Importing an MSBuild .targets file that specifies a single Target, "SetupConanDependencies". This Target uses the conan tool to install dependencies for a project based on a "conanfile.txt" file located in the project root directory.
The output of this Target consists of several files, including a "conanbuildinfo.props" property file. I can Import the generated .props file in my project in order to tell it how to resolve dependencies that have been installed via conan.
Here is a stripped down version of my Target definition (I have tested and verified that it does produce a "conanbuildinfo.props" file):
<Target Name="SetupConanDependencies"
Inputs="$(SolutionDir)conanfile.txt"
Outputs="$(OutDir).conan/conanbuildinfo.props"
BeforeTargets="ClCompile">
<Message Importance="High" Text="Installing project dependencies with conan..." />
<Exec Command="conan install $(ProjectDir)conanfile.txt --install-folder=$(OutDir).conan"/>
</Target>
For my question, the only relevant information is that I have a Target that is generating a .props property file. I would like to Import the generated property file in my project before building. However, I also want the Target to run automatically as part of the build process.
Question
I cannot simply Import the generated .props file inside the .targets file, because it has not yet been built by the Target.
<Import Project="$(OutDir).conan/conanbuildinfo.props"/>
<!-- Adding this line after my Target definition results in the following error, because
the file doesn't exist on disk at the time the .targets file is imported. -->
<!-- Error MSB4019 The imported project "D:\CustomBuildToolExample\Debug\.conan\conanbuildinfo.props" was not
found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. -->
Furthermore, from my current understanding of MSBuild, .props files are supposed to be Imported before .targets files. This seems to imply that I cannot Import the .props file that gets created by my Target at all, because by the time the Target generates the .props file, the project has already imported all of the Properties it will use as part of the build process.
Is there a way to include a .props file that is generated by a Target, so that my project will use the properties defined in that .props file as part of its build process?

Visual Studio Express 2012 and Typescript output directory

I've successfully installed the typescript plugin into the VS.
I would like to change to compiled js files output directory. Currently the js files are being in the same directory with the ts files.
I found a solution that said I should install web essentials and with that I can modify the compiler settings. Unfortunately, the free VS express don't let me to install 3rdparty things. It's ok, but is there any other solution to change the output directory of js files?
In command line it IS a simple --out flag.
I'm not familiar with the limitations of Express, but here's how you do it in the Pro edition without Web Essentials:
Open up the .csproj file inside your project with your favorite text editor. Look for the property groups that look like:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
...
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
...
</PropertyGroup>
and inside both of those add a property like so:
<TypeScriptOutDir>my/dir</TypeScriptOutDir>
If you open up C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\TypeScript\Microsoft.TypeScript.targets you can see how those properties map to the command line flags and how I figured it out.
Like I said I don't know Express and whether it places any limitations on modifying .csproj files so let me know if this works.
not need edit .csproj file, just go to project properties and set "Redirect JavaScript output to directory"
The TypeScript compiler has a flag to redirect output to a directory:
tsc --outDir "Path" app.ts
Finally, I've solved the problem.
The solution:
I added these lines into the csproj file:
<ItemGroup>
<TypeScriptCompile Include="$(ProjectDir)\**\*.ts" />
</ItemGroup>
<Target Name="BeforeBuild">
<Exec Command=""$(PROGRAMFILES)\Microsoft SDKs\TypeScript\tsc" #(TypeScriptCompile ->'"%(fullpath)" --outDir myoutputdirectory', ' ')" />
</Target>
I have this problem in typescript 1.8, after google a little I discovered that the following Output options in the typescript properties project page are incompatible.
If you select Combine Javascript output into file then if you
want to put the .js and .map file in other file, you must to put here
the directory, and do not select Redirect Javascript output
directory
In the other hand if you want to have individual .js files and move
them to a specific directory, then select Redirect Javascript
output directory and maintain deselected Combine Javascript
output into file
For example in my case I want to have a combined .js in a specific directory then may setting are as show in the picture:

TypeScript's Linked Files are unseen by current project's TypeScript files

I've completed rewritting my javascript framework project in TypeScript. Now I'm trying to use these files in many other web projects.
I've tried linking (Linked File) them into the web project. First thing I noticed, I can't change the Build Action to "TypeScriptCompile". .ts files are compiled in their source folder, not where they are linked. The problem is that when creating a new file .ts file in web project, it doesn't see the linked files and I get a TypeScript error.
Also, everytime I try to build a project with Linked TypeScript Files, it crashes Visual Studio.
I'm using AMD and RequireJS. The structure needs to be respected. I'm setting the baseURL to /Scripts/ and my framework and TS files need to be inside that structure.
Does anyone have any idea ?
Here's a sample of what I'm trying
Content from Linked File from a Framework project:
export class Log {
static error (msg: string) { console.log(msg); }
}
Content from File in web project using Linked File:
import fw = module('linkedFile');
fw.Log.error('this file can\'t find the linked file, so this code won\t work');
Thanks !
UPDATE:
The only way I found so far is to copy Frameworks files from the source project to my web project on Post Build:
xcopy /y /e /s /d "$(ProjectDir)Scripts\." "$(ProjectDir)..\..\OtherProject\Scripts\."
The problem with this is we have to edit framework files in the first project, otherwise, our changes will be overwritten.
UPDATE 2:
I'm currently using this script to automatically copy all linked files where they are in the project. You need to edit your CSPROJ file and it has to be a WEB Project. Check the link for a complete description:
http://consultingblogs.emc.com/jamesdawson/archive/2008/06/03/using-linked-files-with-web-application-projects.aspx?CommentPosted=true#commentmessage
<!-- ======================== -->
<!-- Copy linked files -->
<Target Name="_CopyLinkedContentFiles">
<!-- Remove any old copies of the files -->
<Delete Condition=" '%(Content.Link)' != '' AND Exists('$(WebProjectOutputDir)\%(Content.Link)') " Files="$(WebProjectOutputDir)\%(Content.Link)" />
<!-- Copy linked content files recursively to the project folder -->
<Copy Condition=" '%(Content.Link)' != '' " SourceFiles="%(Content.Identity)" DestinationFiles="$(WebProjectOutputDir)\%(Content.Link)" />
</Target>
<!-- Override the default target dependencies to -->
<!-- include the new _CopyLinkedContentFiles target. -->
<PropertyGroup>
<PrepareForRunDependsOn>
$(PrepareForRunDependsOn);
_CopyWebApplication;
_CopyLinkedContentFiles;
_BuiltWebOutputGroupOutput
</PrepareForRunDependsOn>
</PropertyGroup>
<PropertyGroup>
<!-- <PostBuildEvent>$(MSBuildBinPath)\msbuild.exe "$(ProjectDir)_build\site.xml"</PostBuildEvent> -->
</PropertyGroup>
<!-- ======================== -->
When you link a file the path is still relative to its actual location, so you'd have to use a whole bunch of ../../../ to get there.
One option is to set the file to copy on build so it will be copied to your bin folder. I do this for tests but not for releasable code.
Another option is to package your modules to make it easier to use particular versions. You could use a private NuGet repo to do this.

How do I include an XSD file for a configuration section with a NuGet package?

I have a library with a pretty verbose configuration section. I've created an XSD and would like to distribute that with my package so that when a user installs the package, Visual Studio knows about the XSD without the user needing to do anything extra. How do I do this?
You can include any files you want in a nuget package by placing them in the content directory. These will then be installed into the root of your target project when the package is installed. If you're using a nuspec file to build your package you would add the following element under the element.
<files>
<file src="Configuration\MyXsd.xsd" target="content\TargetFolderName" />
</files>
This will create the following file in the target project
\TargetFolderName\MyXsd.xsd
Once the xsd is in the target project visual studio should pick it up automatically for validating your config section.
This has recently become more complicated with SDK style projects and the different ways of referencing nuget packages.
Note the end of this section.
Basically, if a nuget project is referenced by package.config file, the files from the content folder of the nuget package will be copied to the referencing project. If the nuget package is referenced by PackageReference in the project file, the files from the contentFiles folder within the package will be used. It is recommended to include both.
Now if you are using a .nuspec file to configure your nuget package, you can use SynXsiS answer to include the file to both directories:
<files>
<file src="Configuration\MyXsd.xsd" target="content\TargetFolderName" />
<file src="Configuration\MyXsd.xsd" target="contentFiles\any\any\TargetFolderName" />
</files>
However, if you want to configure it in the .csproj file of SDK projects, you have to add the file you want to include in the nuget package into the project file with the following properties:
<ItemGroup>
<None Include="MyXsd.xsd">
<Pack>true</Pack>
<PackagePath>contentFiles\any\any\TargetFolderName;content\TargetFolderName</PackagePath>
</None>
</ItemGroup>
The any\any\ part of the path for the contentFiles specifies for which language (cs, vb, ...) and target framework the file is meant.
Note, that the item not necessarily has to be of type "None" it could also be "Content" and others as described here.
You can find all information for this structure here, general information of the folder structure can be found here and help for the SDK style projects here.

Missing Second-Level Binary References with MSBuild Web Deployment

I am trying to do a Jenkins-based automated build/deployment of a web application (.NET 4.0). The web application project has several project references, which in turn have binary references third party DLLs.
The problem:
The second-level references (references of project references) are not pulled into the bin folder in the obj\<CONFIGURATION>\Package\PackageTmp\bin folder, used for building deployment packages.
When I build in the visual studio, the second level references are pulled into the regular build output directory.
When building with MSBuild, second level dependencies are not pulled into the regular output directory, nor into the PackageTmp\bin directory.
This is confirmed by MS as a Won't-Fix issue here.
Related questions here, here and here either do not match my problem, or offer solutions that don't work. I've reviewed all answers, not just the accepted ones.
My build command looks like this (using MSBuild 4.0):
MSBuild MySolution.sln /p:Configuration=Integration /p:platform="Any
CPU" /t:Clean,Build /p:DeployOnBuild=true /p:DeployTarget=Package
/p:AutoParameterizationWebConfigConnectionStrings=false
I've tried to manually edit Reference elements in project files, adding <Private>True</Private>, with no success.
I am trying to work around this known issue, so that my second-level dependencies are automatically and correctly pulled into the web publishing temp directory.
My current attempt combines the general approach here (customizing the web publishing pipeline by adding a MyProject.wpp.targets file next to the web project file), combined with some MSBuild code for finding DLLs here. So far this has either produced no results or broken the project file. I am new to custom MSBuild code and find it pretty arcane.
My Question: I am looking for a more complete example that works in my specific case. I think the goal is to intervene in the web publishing pipeline that gathers files for copying to the package temp directory, and adding the second-level dependencies to it.
My custom MyWebProj.wpp.targets looks like this:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<BRPathFiles Include="$(SolutionDir)..\Common\**\*.dll;$(SolutionDir)**\*.dll" />
<ConfigPathFiles Include="$(SolutionDir)..\Common\**\*.config;$(SolutionDir)**\*.config" />
</ItemGroup>
<Target Name="CopySecondLevelDependencies" BeforeTargets="CopyAllFilesToSingleFolderForPackage">
<RemoveDuplicates Inputs="#(BRPathFiles->'%(RootDir)%(Directory)')">
<Output TaskParameter="Filtered" ItemName="BRPaths" />
</RemoveDuplicates>
<RemoveDuplicates Inputs="#(ConfigPathFiles->'%(RootDir)%(Directory)')">
<Output TaskParameter="Filtered" ItemName="ConfigPaths" />
</RemoveDuplicates>
<CreateItem Include="%(BRPaths.Identity);%(ConfigPaths.Identity);">
<Output ItemName="FileList" TaskParameter="Include"/>
</CreateItem>
<CreateItem Value="#(BRSearchPath);$(ConfigSearchPath)">
<Output TaskParameter="Value" PropertyName="SecondLevelFiles" />
</CreateItem>
</Target>
<ItemGroup>
<FilesForPackagingFromProject
Include="%(SecondLevelFiles->'$(OutDir)%(FileName)%(Extension)')">
<DestinationRelativePath>$(_PackageTempDir)\bin\%(FileName)%(Extension) </DestinationRelativePath>
<FromTarget>CopySecondLevelDependencies</FromTarget>
<Category>Run</Category>
</FilesForPackagingFromProject>
</ItemGroup>
</Project>
Assuming you have collected all libraries needed at runtime in a folder outside your solution/project, have you tried just using post-build events to copy all these libraries to your main project target directory (bin) and then include that directory in your deployment package using Sayeds method: http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx (also available in this post: How do you include additional files using VS2010 web deployment packages?)?
I have (among others) the following line in my main project's post-build events:
xcopy "$(ProjectDir)..\..\Libraries\*.dll" "$(TargetDir)" /Y /S
In addition to this, I have added the following lines to my .csproj file:
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
PostBuildLibraries;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="PostBuildLibraries">
<ItemGroup>
<_PostBuildLibraries Include="$(TargetDir)**\*" />
<FilesForPackagingFromProject Include="%(_PostBuildLibraries.Identity)">
<DestinationRelativePath>$(OutDir)%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
Be sure to add these lines after the import of the "Microsoft.WebApplication.targets". Check out the links above for more details.
This makes all the desired libraries available after each build (copied to the project's target directory) and each time I create a deployment package (copied to the obj\<CONFIGURATION>\Package\PackageTmp\bin).
Also, since I'm building my main project, not my solution, I'm using the $(ProjectDir) macro instead of the $(SolutionDir).

Resources