Deploying shared server controls with web.config transforms - visual-studio-2010

I'm using teamcity to deploy our web application to several servers using msbuild and webdeploy.
I have a configuration per customer / environment combination - for example:
Internal-Dev
Customer1-Test
Customer1-Pilot
Customer1-Live
Customer2-Test
Customer2-Pilot
Customer2-Live
I only need these configurations so that the deployment process can use web.config transformations to set the appropriate connection strings and other settings for the installation.
The problem that I have is that I have a shared web server controls project which really only needs two configurations - debug and release - but I need to copy all the above configurations into this project in order to get them to work. If I delete Customer2-Pilot from the shared project, I can't deploy to customer 2's pilot server because it is looking for the Customer2-Pilot configuration for the shared project which doesn't exist.
Currently, I copy the application's configuration names into the shared project but that is impractical as we have several applications each going to different customers so the shared project could get dozens of configurations which are all copies of Release or Debug
I would like to be able to configure the build system so that I can say that the Internal-Dev configuration of the web application project uses the shared project's Debug configuration and all the other configurations use the shared project's Release configuration. This is possible from within the IDE, using the configuration manager which can tie a solution configuration to individual project configurations but I'm not sure how to do this from within teamcity.
My current teamcity configuration is using the MSBuild runner with the web application's project file as the build file path and the configuration parameters set to deploy it to the relevant server with the correct configuration after it has been built. The shared project is in a sub-repository of the web application repository so it is fetched and built automatically.
Is there any way that I can change this set up to get what I want? Do I need to change the build file path to be the solution instead of the project so that I can use the configuration manager settings to configure it?

It turns out that this is as simple as changing the build file path parameter to be the solution file instead of the project file. This means that you specify a solution configuration instead of a project configuration. Solution configurations are managed in the configuration manager and you can specify the configuration of each project in the solution configuration so it all works nicely.
I have two projects that need to be published (a web application and a WCF service application) and they depend upon five other class library projects. I have it set up so that the class library projects are built using either the Debug or Release configurations and the two projects that have config files that need to be transformed have one configuration per system.
One thing of note. In the old set up I had to have two build steps - one to build and deploy the web application and one to build and deploy the WCF service application. When I use the solution file as the build file, I don't need two steps any more as they are both part of the solution and so they both get built and deployed.

Related

Intellij Idea - Define custom and different Gradle User Home by Project

I am working with ideaIC-2020.2.3
I am able two open two windows to open two different projects for each window respectively. These projects are based on Gradle, for example
Spring Framework
Spring Integration
About settings I am able to define the gradle user home location, but it is common for all the projects. I want to know (if is possible - by the IDE itself or through a special plugin) define for each Project a custom and isolated (or different) gradle user home location. I tried for each project do right clic and Open Module Settings and does not exist something to accomplish this goal.
Observation: in STS/Eclipse - for Maven is possible for example that for each workspace import a custom and different settings.xml file indicating a specific and different repository.
It is not possible. Please vote for IDEA-163506.

How to customize FreeMarker template by using Jar?

Some times ago, I used Alfresco 5.2 Community Edition. When I needed to develop some kind of customization, I used the Alfresco Maven SDK with three different Maven archetypes, it was:
Alfresco Repository AMP;
Alfresco Share AMP;
Alfresco all-in-one (AIO).
By using this SDK I developed AMP files that overlaid on either the alfresco.war or share.war by using the module management tool.
Now I am using Alfresco 4.2.2 Enterprise Edition and the problem is that all the customizations over the years have been performed directly on the servers in the exploded WAR's.
This approach is described here: Packaging Approaches
Unpackaged Files or ZIP
Many development environments employ a build process that can execute
a script to move unpackaged modified files from source control into
the web application's exploded WAR file. Ant, bash, or some scripting
language can all be good ways to do this ...
Moving unpackaged files has the advantage of being quick and easy to
understand ...
And further:
Deployment Locations
One solution is to use a permanently exploded deployment (instead of
deploying an Alfresco WAR file under /webapps). Create a directory
called alfresco under the webapps directory and extract the contents
of alfresco.war into it. Then copy your files to
../webapps/alfresco/WEB-INF/ and restart Tomcat ...
Thus, I can't use AMP-customizations(otherwise all previous developments will be deleted). As far as I know, I can use an alternative- JAR-customization.
As described in the same document:
JAR
As of v3.4, the Share web application supports overrides that are
packaged as JAR files. This allows multiple customizations to be
isolated from each other, and order of selection can be predicted.
Static files such as JavaScript, CSS, or image files that would
normally be placed in the web root of the Share application can also
be packaged into these JARs ...
While it's possible to avoid the overwriting problem (at least in
Tomcat) by placing these JAR files in tomcat/shared/lib ...
However, I can not take advantage of this approach either. For example, I need to override the FreeMarker template:
/opt/tomcat7/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/components/form/service-note/service-note-order-things.ftl
I create the appropriate directory structure in IDE, change the template in some way, and build the Jar file. Then I put it in tomcat7/shared/lib (I also placed it in tomcat7/webapps/share/WEB-INF/lib, but also without success) and restart the application server.
After restarting, I don't see my changes - the template remained the same. Moreover, if I try to add another template to the same directory (.../service-note/...), a new template there does not appear.
In my Tomcat installation shared classloader is configured properly.
What am I doing wrong? How to override static resources by using JAR?
I would be very grateful for the information. Thanks to all.
It is necessary to use the SurfBug debugging tool to identify the template file (Template Type property).
Then develop the Spring Surf extension module - "are the preferred way of customizing many of the Alfresco Share user interface features" - and pack it into the Jar.
Then I should use the Module deployment which is available through the web-
script at:
http://host:port/share/service/modules/deploy
The FTL can be customizing as follows:
Place the new content before/ after the certain #region;
Replace the content of the certain #region with the new content;
Remove the certain #region completely.
In the file system, we will have the same unmodified template, because Spring Surf writes to an in-memory model and then allows extensions to manipulate that model before the model is flushed to the output stream.
See also:
Customize Alfresco Share FreeMarker templates
About FreeMarker extensibility directives

Creating an external Maven packaging POM

It seems like common practice to create a packaging POM that packages and sets up the deployment environment for submodules within a project.
However is it possible to create a packaging POM outside of a project that can add functionality to it's deployment process?
I'm dealing with a situation where I have to make use of an in-house Maven project that builds up a web server with a default web service that provides certain functionality. I want to be able to build a custom version of that project that adds an additional web service to the container and tweaks the default configuration (without checking into that projects code repo).
Is this something that is supported by Maven or do I have to hack something together to make this type of deployment process work?

How to setup multiproject structure with maven?

I'm fairly unexperienced and all new to the whole world of build tools so here's my situation: I am developing a webapp with JSF, PrimeFaces and Hibernate on wildfly-9.0.2-final. All java files (incl. ManagedBeans, DAOs, Model classes, etc.) are currently in a regular eclipse java project called MyApp-CORE. There is no html or any other resources in that project, but all the third-party libraries like PrimeFaces, commons-xy, etc. Then I got two dynamic web projects with all the .xhtml files and stuff. Both web projects include the CORE in their build path (all done via eclipse built-in tools). Basically I followed Structure for multiple JSF projects with shared code so far. All projects are versioned using Git. I was now asking myself how to mavenize the whole thing and also how to properly include tests. The final result should be:
I want a build file for each web project that includes the CORE dependency and all of it's transitive dependencies, creates a .war file and deploys it either on the production system or locally (Depending on some parameters I want to be able to maintain).
This buildfile could then for instance test and build the CORE and then the .war file.
Since I'm using JSF, mostly the only option for testing is JSFUnit. Should I test each web project individually and put all the test cases there (which would be highly redundant because they're mostly the same, just a few features are different) or should I rather create a separate web project called MyApp-TEST which tests the CORE.jar and also - depending on some configuration - each web project.
I've already created a structure that makes it possible to include the core in the web project but unfortunately I loose the perks of hot deployment in wildfly when just including it as a dependency from my local maven repository.
So, to summarize it:
What would be a best practice for this setup, eventually leading to a continuous integration scenario?
How should I include the test cases (full integration tests that test actual UI behaviour)?
Which Tool (Maven, Gradle, Ant, etc.) would be best for that task?
Keep using hot deployment for smooth development?
Thanks in advance for any comments, hints or shared experience!

Share configs of a project between several projects in TeamCity

I have a project called SPI with 15 configs. Those configs have dependency on a build config of project A.
I have been asked to run those same 15 SPI configs for project B and C. A, B and C are not dependent on each other. One way to do it is replicate the SPi project for B and C. But maintenance will be a nightmare. DO you have any suggestions on how to address this situation? DO you think I should use meta-runner? It will reduce the maintenance but not remove it. Any input is highly appreciated.
Which version of Teamcity are you using? Teamcity 8 has Build Configuration templates. I'm not sure when they were first introduced but if you have access to them, I'd recommend using them.
You can create build configuration templates from existing ones. So in your case, you can ask to create a build configuration template from each of the configs you have in project A. You can then modify those templates to make them generic and keep the customization specific to project A in project A itself. Then, base projects B and C's build configurations on the templates and simply customize the parts you need to in both those projects.
Here's more information: http://confluence.jetbrains.com/display/TCD8/Build+Configuration+Template
Build configuration templates is how we have set up our build system to build multiple branches of the same source code. When something must change, the changes are made to the templates which means they are automatically inherited by all projects that leverage said templates.

Resources