Use Maven Cargo to install Wildfly with Keycloak - wildfly

I'm trying to use Maven Cargo to produce a Wildfly container and get Keycloak running on it. I've been at this for a while now and the way I see it there are two ways to go about it. I could either use an artifact installer for Wildfly and then try to deploy Keycloak to it, or I could use a zip installer and have it install Keycloak's appliance build. I have the basics of both solutions working although neither of them work all the way.
They both seem to have downsides. If you use the artifact installer you have a more stable installer, but deploying the war takes quite a bit of lower level configuration for Wildfly. (Deployment Instructions). On the other hand, the zip installer requires finding a place to download a distribution from and then manipulating it a bit before Cargo will recognize it, because the zip structure is not what Cargo seems to be expecting.
I'm getting the zip from here: https://repository.jboss.org/nexus/content/repositories/releases/org/keycloak/keycloak-appliance-dist-all/1.0.2.Final/keycloak-appliance-dist-all-1.0.2.Final.zip)
Thanks in advance guys.

I figured out a way to do this and attached the relevant pom snippet. The only oddball piece here ends up being the files section. It's being used to deploy a database file that has a couple test users, realms, apps, etc.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.6</version>
<configuration>
<container>
<containerId>wildfly8x</containerId>
<!-- <log>${basedir}/target/cargo.log</log> -->
<!-- <output>${basedir}/target/wildfly.log</output> -->
<home>${project.basedir}/target/cargo/installs/keycloak-appliance-dist-all-1.0.4.Final/keycloak-appliance-dist-all-1.0.4.Final/keycloak</home>
<artifactInstaller>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-appliance-dist-all</artifactId>
<version>1.0.4.Final</version>
</artifactInstaller>
</container>
<configuration>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.servlet.users>root:root:ManagementRealm</cargo.servlet.users>
<cargo.jboss.configuration>standalone</cargo.jboss.configuration>
</properties>
<files>
<file>
<file>${project.basedir}/WildflyKeycoakConfigs/keycloak.h2.db</file>
<todir>/data</todir>
</file>
</files>
</configuration>
</configuration>
</plugin>

Related

AEM cloud, how do you install groovy console?

There is a groovy console for AEM:
https://github.com/CID15/aem-groovy-console
However, I dont know how to install it for AEM cloud.
The instructions say to download it and run a local installer, which will install groovy console some how on the local machine.
However, this wont help the other users of our project, and wont work when the project is built on the cloud envs.
Presumably, we need to configure mvn to automatically download and install it, or possibly we have to put some sort of lib file somewhere in our ame project source?
Any suggestions?
It's taken some effort to find a solution. Here we are installing the groovy console via the aem-easy-content-upgrade tool which uses it.
There are three files to edit:
pom.xml, all/pom.xml and filter.xml
pom.xml
<dependency>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.complete.cloud</artifactId>
<type>zip</type>
<version>LATEST</version>
</dependency>
all/pom.xml
<embedded>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.complete.cloud</artifactId>
<type>zip</type>
<target>/apps/aemlab-vendor-packages/install</target>
</embedded>
<dependency>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.complete.cloud</artifactId>
<type>zip</type>
</dependency>
/all/src/main/content/META-INF/vault/filter.xml
<filter root="/apps/aemlab"/>
<filter root="/apps/aemlab-vendor-packages" />
Then rebuild with your usual 'mvn clean install -PautoInstallPackage' or similar.

Force unpacking with maven-dependency-plugin

Im am using Maven 3.2.1 with Eclipse Kepler. I have a dynamic web project which has a dependency to another component which includes some JSPs. I now want the JSPs from the dependency to become part of the web root of the dynamic web project. I chose to accomplish this by using unpack goal of the maven-dependency-plugin.
I added a plugin definition to unpack the JARs into /target/m2e-wtp/web-resources. Unfortunatley Eclipse from time to time cleans this folder and teh JSPs are gone. In order to unpack them again I have to delete the target/dependency-maven-plugin-markersfolder. Otherwise the plugin will not unpack the files again.
Is it possible to force the unpacking and ignore the plugin markers?
Is there a better way to get web resources from a dependency into my Dynamic Web Project?
Yes there's a better way, but it's not compatible with Tomcat's "serve module without publishing" feature (or Weblogic's equivalent thing)
Remove your maven-dependency-plugin configuration and add your dependency as a war overlay instead. If your dependency is a war, it'll be automatically recognized as an overlay (http://maven.apache.org/plugins/maven-war-plugin/overlays.html). If it's a zip or a jar, you need to add a specific configuration to your maven-war-plugin definition. Something along :
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<overlays>
<overlay>
<!-- /!\ must also be added as a project dependency-->
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<type>jar</type>
<targetPath>relative/path/to/contextroot</targetPath>
</overlay>
</overlays>
</configuration>
</plugin>
Before deployment, resources will be unzipped under target/m2e-wtp/overlays/bar-version.jar/ and then deployed onto your application server

Eclipse on-click deploy to remote Tomcat

I've been looking for this all-over the internet and somehow I can't find a easy way to do it.
What I need is really simple and I believe that many of you probably do it already:
- I develop Java Web Apps in Eclipse and so does my team;
- we have a tomcat7 server running on a Ubuntu machine which works as a centralized Dev environment;
- I would like to click a deploy button and send the new data to the server and deploy it (reload it), instead of exporting a war every time and manually upload it to server.
Up till now seems like the only way to do it is with Maven plugin for eclipse, which uses the manager/HTML interface of tomcat.
Problem: I just can't get it to work. But somehow I can't find a simple walk through that explains how to do it. I'm not too experienced with eclipse or Linux but the configuration of local tomcat servers seems pretty straightforward. I don't understand why is so hard to install a remote one.
Could you please help me out by explaining in detail how to do it? Thank you in advance for you patience.
Yes, you can use Tomcat7 Maven Plugin. Here is the steps:
1) Install Maven Integration for Eclipse (m2eclipse) to your eclipse from Eclipse Marketplace etc.
1.1) Navigate to Help -> Eclipse Marketplace and search "Maven Integration for Eclipse".
2) From eclipse, create a maven project.
2.1) Navigate to File -> New -> Project... -> Maven -> Maven Project.
2.2) Click Next (Leave all fields with default).
2.3) Select "maven-archetype-webapp" and click Next.
2.4) Enter arbitrary value on Group Id and Artifact Id. (e.g. "org.myorg" for Groupd Id and "myapp" for Artifact Id) and click Finish. (You will see pom.xml in your project's root.)
3) Edit pom.xml like this: (Replace yourhost below with your hostname or ip address.)
<project ...>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>http://yourhost:8080/manager/text</url>
</configuration>
</plugin>
</plugins>
</build>
</project>
4) Add following lines to your CATALINA_BASE/conf/tomcat-users.xml and restart your tomcat.
<tomcat-users>
...
<role rolename="manager-script"/>
<user username="admin" password="" roles="manager-script"/>
</tomcat-users>
5) From eclipse, run tomcat7:redeploy goal.
5.1) Right click your project and navigate to Run As -> "Maven build...".
5.2) Enter tomcat7:redeploy to Goals and click Run.
6) Once you create the run configuration setting above, you can run tomcat7:redeploy goal from Run -> Run Configurations.
Please refer to the following documents for details:
http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Configuring_Manager_Application_Access
http://tomcat.apache.org/maven-plugin-2.1/index.html
http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/plugin-info.html
If you use another user instead of admin with empty password (which is plug-in's default), you need to create %USERPROFILE%.m2\settings.xml and edit pom.xml like below:
%USERPROFILE%.m2\settings.xml:
<settings>
<servers>
<server>
<id>tomcat7</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
</servers>
</settings>
%USERPROFILE% is your home folder. (e.g. C:\Users\yourusername)
pom.xml:
<configuration>
<server>tomcat7</server>
<url>http://localhost:8080/manager/text</url>
</configuration>
Add server tag.

How to explicitly save cobertura-enabled jars in my maven repo?

So we have continuous integration in Jenkins of our maven builds. We have a number of module builds, which are packaged together in an assembly build. The assembly build is then a dependency of our integration test build, which installs the full package, starts it, runs tests, and shuts it down. We have nightly cobertura reports running on the module unit tests, but now we want nightly cobertura reports from the integration tests. I'm comfortable with our ability to setup customized builds for the cobertura reporting using the cobertura-maven-plugin.
The problem is, I don't want to do this all the time, so how do I differentiate this jar in the maven repository? Is there some way to use a descriptorRef (like jar-with-dependencies) to get it in the same maven repository but with slightly different coordinates? Then the next question of course is how do I get the assembly build to have different coordinates? Of course this is likely the same or similar answer.
I am not really a maven guy, but I think you can deploy this artfifact specially (I use ivy and have a special deploy configuration for the instrumented jars):
Have a look at classifiers:
Deploy an artifact with classifier
Classifiers are the additional text given to describe an artifact.
artifact-name-1.0-bin.jar artifact-name-1.0-dev.jar
artifact-name-1.0-prod.jar
From the above artifact names, classifiers can be located between the
version and extension name of the artifact.
bin is used to describe that the artifact is a binary.
dev is used to describe that the artifact is for development.
prod is used to describe that the artifact is for production.
To add classifier into your artifact for your deployment, set the text
to the classifier parameter.
mvn deploy:deploy-file -Durl=file:///C:/m2-repo \
-DrepositoryId=some.id \
-Dfile=path-to-your-artifact-jar \
-DpomFile=path-to-your-pom.xml \
-Dclassifier=bin
https://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html
I have not understood correctly but If you would like to use over and over again your aggregated jar you can use install plugin?
Let's make clear steps,
Assemble your file
Install it to your local repository
Use this file
In order to make it you should use install plugin with install-file goal after the phase you aggregate your file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<phase>anyphase</phase>
<goals><goal>install-file</goal></goals>
<configuration>
<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>${project.version}</version>
<packaging>pom</packaging>
</configuration>
</execution>
</executions>
</plugin>
Then simply reference your jar wherever you want with the necessary coordinates.

How to add a jar to the server lib for *embedded* JBoss?

I need to add a crypto provider to the embedded JBoss used by Seam for integration tests.
For the regular JBoss it's a simple matter, just drop the files into the /lib folder of the server instance. With the embedded JBoss, however, things seem to be different. I've tried putting the jars in /embedded-jboss/bootstrap/lib and /embedded-jboss but no change, the classes are not seen.
I've read http://community.jboss.org/wiki/EmbeddedAndJavaSE and also looked in the source of org.jboss.embedded.Bootstrap but I haven't found a way yet. The build is done with Maven if it matters.
Thanks a lot for any suggestions.
I found an answer in the meantime: they can be added to the classpath of the plugin that runs the tests, like below. Works for me.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- snip -->
<additionalClasspathElements>
<additionalClasspathElement>add/here/your/jar</additionalClasspathElement>
</additionalClasspathElements>