openliberty / ci.gradle Goto Github PK
View Code? Open in Web Editor NEWGradle plugins for managing Liberty profile servers #devops
License: Apache License 2.0
Gradle plugins for managing Liberty profile servers #devops
License: Apache License 2.0
Create the first release of the Liberty Gradle plug-in.
We should make sure that this plugin appear on the list of plugins on https://plugins.gradle.org/.
Deploy to remote server in gradle. "OpenLiberty/ci.ant#8"
Ensure integration tests are running with each pull request.
I want to be able to start multiple servers from a single gradle file but can't do this as the Liberty stanza applies to the whole build project. Something like this would be nice:
task startMyServer(type: LibertyStart) {
serverName = 'myServer'
}
task startOtherServer(type: LibertyStart) {
serverName = 'otherServer'
}
In Liberty.groovy, you add the tasks
project.task('installLiberty', type: InstallLibertyTask) {
description 'Installs Liberty from a repository'
logging.level = LogLevel.INFO
}
When you don't specify a group, the task is added to the other
group in the IDE. In big enterprises like mine where my build system has hundreds of tasks for a particular project and that other
group gets huge. if you were to simply change those tasks to something like this
project.task('installLiberty', type: InstallLibertyTask) {
description 'Installs Liberty from a repository'
group 'Websphere Liberty'
logging.level = LogLevel.INFO
}
That would pull those tasks out of other
and into Websphere Liberty
in your IDE. Its a simple change that increases usablity
Hi there!
The issue is as follows. When you pass 'whenFileExists=ignore' to the installFeature task, and the feature exists, IBM's featureManager returns 22 even though you are telling it to ignore it . Gradle will consider this 22 code as a failure. I wonder if the plugin, provided the ignore flag was passed, could translate the 22 to 0.
Kind regards,
Cesar
I was planning to use the installLiberty task to install Liberty as part of a build if it didn't exist, but it seems that the plugin won't load successfully unless the 'bin/tools/ws-server.jar' dependency is defined (which is only available if you've already downloaded Liberty). Without classpath files('c:/wlp/bin/tools/ws-server.jar')
the plugin can't be loaded successfully and I get the following stacktrace when running any task (I've cut it down):
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'liberty-test'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory
.java:54)
...
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'liberty']
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction
.java:117)
...
Caused by: org.gradle.api.GradleException: Could not generate a proxy class for class net.wasdev.wlp.gradle.plugins.task
s.RunTask.
...
at net.wasdev.wlp.gradle.plugins.Liberty.apply(Liberty.groovy:47)
at net.wasdev.wlp.gradle.plugins.Liberty.apply(Liberty.groovy)
...
Caused by: java.lang.ClassNotFoundException: com.ibm.wsspi.kernel.embeddable.ServerBuilder
... 61 more
Looking at the stack trace, the unresolved classes are in the RunTask, which is next to be loaded in Liberty.groovy after the InstallLiberty task.
Hi everyone,
I am trying to install features on my Liberty server using this plugin. When i run libertyFeatures I get this error: `Execution failed for task ':installFeature'.
To install a feature, you must accept the feature's license terms and conditions.`
I am using the 2.0 version of the plugin.
Here is my configuration. Does anyone have any ideas?
liberty {
installDir = "${project.libertyServerDir}/wlp"
clean = true
timeout = "10000"
deploy {
file = "${buildDir}/${warName}"
}
features {
name = ['jsp-2.2', 'jaxws-2.2', 'jdbc-4.0']
acceptLicense = true
}
install {
baseDir = libertyServerDir
type = "webProfile7"
}
packageLiberty {
archive = "${project.buildDir}/${project.deployName}.zip"
include = "usr"
}
server {
name = "defaultServer"
}
}
Thank you for the help,
Jec
This response in StackOverflow suggests that I can extend OpenLiberty with additional JARs as shared libraries, so my app WARs can be incredibly skinny. Is there any way the installation of such shared libraries be done through this plugin? I know both the maven and gradle plug-ins install whole run-time server, I just need a way to slap on some additional jars on top as shared libraries
Thanks
Btw, is there a good example of demo project using the Gradle plugin?
for the deploy task, why are you requiring people to specify files? Files change, all the time. names change, locations change, etc. Why don't you make a more iron clad way
configurations{
libertyDeploy
}
dependencies {
libertyDeploy project(":app-war")
}
that way a subproject can be automatically deployed. no need to figure out how in the world to extract the file name from one subproject to another. This is a much more reliable way. Not only that, this will also add an implicit dependsOn that will fire the :app-war:war task every time you do a deployment automatically.
Its just a much more "gradle" way of doing things. the approach thats built in right now has a very "ant" feel to it.
Same as OpenLiberty/ci.ant#35.
Add a task for installing features based on https://github.com/WASdev/ci.ant/blob/master/src/main/java/net/wasdev/wlp/ant/InstallFeatureTask.java.
Hi,
I'm trying to import the plugin as is stated in the readme.md file.
To simplify matters I created an empty project and copied the JAR file into it. The build.gradle file looks like this (although I already tried several versions):
`buildscript {
dependencies {
classpath files('liberty-gradle-plugin-1.0-SNAPSHOT.jar')
classpath files('c:/devend/wlp/bin/tools/ws-server.jar')
}
}
apply plugin: 'liberty'
liberty {
wlpDir = 'c:/devenv/wlp'
serverName = 'test'
}`
I'm always getting this error message:
c:\devenv\projects\test>gradle libertyRun
FAILURE: Build failed with an exception.
Where:
Build file 'C:\devenv\projects\test\build.gradle' line: 6
What went wrong:
A problem occurred evaluating root project 'test'.
Failed to apply plugin [id 'liberty']
Plugin with id 'liberty' not found.
Can you help me with this please?
If so, does that conflict with configuring a <webApplication>
in server.xml. My understanding is that it does, or perhaps it is the other way around. In any event, I believe they are incompatible methods of deploying a web application in Liberty, correct?
It would be nice to have the "os" parameter in gradle, it can help to reduce the package size result.
More information: http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/twlp_setup_package_server.html?cp=SSEQTP_8.5.5%2F1-3-11-0-3-2-1-6
Update the installLiberty
task to use the StartParameter to detect the offline mode instead of a separate parameter in the InstallExtension
extension.
Unlike in the maven plugin where there is a <configFile>src/main/liberty/config/server.xml</configFile>
element that you can add to the config to use when creating a server this isn't an option with the gradle plugin
How can we start/stop multiple server in different port.
This stack trace shows up whenever a non xml file is placed in configDirectory
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
at net.wasdev.wlp.maven.plugins.ServerConfigDocument.parseDocument(ServerConfigDocument.java:296)
at net.wasdev.wlp.maven.plugins.ServerConfigDocument.parseDropinsFilesVariables(ServerConfigDocument.java:416)
at net.wasdev.wlp.maven.plugins.ServerConfigDocument.parseConfigDropinsDirVariables(ServerConfigDocument.java:407)
at net.wasdev.wlp.maven.plugins.ServerConfigDocument.initializeAppsLocation(ServerConfigDocument.java:140)
at net.wasdev.wlp.maven.plugins.ServerConfigDocument.<init>(ServerConfigDocument.java:66)
at net.wasdev.wlp.maven.plugins.ServerConfigDocument.getInstance(ServerConfigDocument.java:86)
at net.wasdev.wlp.maven.plugins.server.PluginConfigSupport.isAppConfiguredInSourceServerXml(PluginConfigSupport.java:243)
at net.wasdev.wlp.maven.plugins.applications.InstallAppMojoSupport.validateAppConfig(InstallAppMojoSupport.java:231)
at net.wasdev.wlp.maven.plugins.applications.InstallAppsMojo.installLooseApplication(InstallAppsMojo.java:134)
at net.wasdev.wlp.maven.plugins.applications.InstallAppsMojo.installDependencies(InstallAppsMojo.java:101)
at net.wasdev.wlp.maven.plugins.applications.InstallAppsMojo.doExecute(InstallAppsMojo.java:68)
at org.codehaus.mojo.pluginsupport.MojoSupport.execute(MojoSupport.java:122)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)```
This is a minor issue with unexpected " The XXX was configurated but was not found..." message.
Just clone the sample.servlet, git clone https://github.com/WASdev/sample.servlet.git
and add assemble.dependsOn 'libertyPackage'
to the build.gradle file and run gradle build
[sample.servlet]$ gradle build
:installLiberty
:libertyCreate
:compileJava
:processResources NO-SOURCE
:classes
:war
:installApps
:libertyPackage
The bootstrapPropertiesFile was configured but was not found at: /private/tmp/apps1/tmp/tmp/sample.servlet/src/main/liberty/config/bootstrap.properties
The server jvmOptionsFile was configured but was not found at: /private/tmp/apps1/tmp/tmp/sample.servlet/src/main/liberty/config/jvm.options
The server serverEnv was configured but was not found at: /private/tmp/apps1/tmp/tmp/sample.servlet/src/main/liberty/config/server.env
:assemble
:libertyStart
:compileTestJava
:processTestResources NO-SOURCE
:testClasses
:integrationTest
:libertyStop
:test
inside the test block
:check
:build
Calling the installFeature task should invoke the installLiberty task, otherwise you have to add installFeature.dependsOn('installLiberty') to the build.gradle file.
I just had one of my testers call me up about this. The liberty distro that we are using with the plugin uses runtimeUrl
and pulls the file out of our artifactory server. Its 160 megs and takes a while to get to the desktop. I had a tester kill the build 3 times before they realized that it wasn't hung, it was just downloading the file. Add additional project.logger.lifecycle()
statements to tell the user whats going on, if its downloading something, then tell them. possibly dump a status bar to the screen or something. The more you tell users, the less support calls I get and support calls = money.
I started seeing this error over the weekend. Seems like there was a 1.1 release of other projects, but not this one. Does the project need a 1.1 release as well?
> Could not resolve net.wasdev.wlp.ant:wlp-anttasks:1.1-SNAPSHOT. Required by: com.ibm.watson.wea.concierge:concierge-test:0.0.1-SNAPSHOT > net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:1.0-SNAPSHOT > Could not resolve net.wasdev.wlp.ant:wlp-anttasks:1.1-SNAPSHOT. > Could not parse POM https://oss.sonatype.org/content/repositories/snapshots/net/wasdev/wlp/ant/wlp-anttasks/1.1-SNAPSHOT/wlp-anttasks-1.1-20151107.030858-30.pom > Could not find net.wasdev.maven.parent:java7-parent:1.4-SNAPSHOT.
Thanks!
Update installLiberty to either use Maven Central by default or provide a simple mechanism for specifying that you want to install an image from Maven Central. Currently can be configured by setting the runtimeUrl to the specific location of the file on Maven Central but instead it would be better to be able to specify some configuration options, similar to ci.maven.
Seems you have been working on 1.1 for a year now. The fact that this is snapshot means i can't deploy it to production in my environment. (corp rules). planning a release any time soon?
The user could specify the features to be installed. "OpenLiberty/ci.ant#38"
I have the latest 1.1 SNAPSHOT jars for ci.gradle and can't build my tasks due to a failure with installFeature.
I am using the following settings:
liberty {
installDir = "${libertyBaseDir}/wlp"
serverName = "AccessTokenOpenIDRelyingParty"
userDir = "../access-token-rp-wlpcfg"
install {
licenseCode = "${projectLicenseCode}"
version = "16.0.0_04"
baseDir = "${libertyBaseDir}"
}
packageLiberty {
include = "usr"
archive = "build/libs/AccessTokenRPApp.zip"
}
features {
name = ["servlet-3.1","jsp-2.3","openidconnectclient-1.0","openidconnectserver-1.0"]
acceptLicense = true
whenFileExists = "ignore"
}
}
Here is the output of the logs:
Execution failed for task ':access-token-rp-application:installFeature'.
> CWWKM2002E: Failed to invoke [/Users/ernani/Downloads/sample.microservices.security/liberty.runtime/wlp/bin/installUtility, install, --acceptLicense, servlet-3.1,jsp-2.3,openidconnectclient-1.0,openidconnectserver-1.0]. RC= 21 but expected=[0, 22].
According to the error code, the installUtility page at https://www.ibm.com/support/knowledgecenter/SSD28V_9.0.0/com.ibm.websphere.wlp.core.doc/ae/rwlp_command_installutility.html
Lists the following potential issues:
A runtime exception occurred because of one or more of the following conditions:
Is this build bugged?
Can someone help? Thanks a lot in advance.
When a configDirectory is specified in a build file, the contents of the directory are not being copied to the server directory.
Same as OpenLiberty/ci.ant#32.
(Example project: sample-mpconf)
When another subproject generates the jar needed by the building project, a combination of missing resources or dependencies in build.gradle
makes the generated xml fail to find its needed classes and resources.
Create the same scenario "OpenLiberty/ci.ant#2" but in gradle.
my company won't let me contribute to this, but you could ease fears and add value by implementing incremental builds. for example, task installLiberty
currently, every time you do something installLiberty
is run. But, since there are no incremental builds setup, you never really know if it did anything or not. The log just shows that it ran. So the user asks the question, "did it install anything?", "does it really reinstall on every run?"
if you were to add something like this to the task
class InstallLibertyTask {
@Input
String license
@Input
String downloadurl
@OutputDirectory
File folderToInstallLibertyIn
def InstallLibertyTask(){
folderToInstallLibertyIn = project.wherever.this.value.is.in.extension.
downloadurl= project.wherever.this.value.is.in.extension
license=project.wherever.this.value.is.in.extension
}
}
what would happen is gradle would look to see if any of those annotated values changed since the last time it ran. if it didn't detect a change, then you would get
:installLiberty UP-TO-DATE
in your log. this tells the user that it just checked the install but didn't actually install anything. it also makes the build much faster because gradle will skip the step if it feels that everything is up to date.
I would make the change, but my company doesn't allow it and i would run into major legal issues.
I am getting a really strange error trying to deploy a WAR which is provably there and available (see screenshot attahced below). Here is a snippet of my build file - any clue:
...
apply plugin: 'liberty'
apply plugin: 'war'
dependencies {
//Java EE
providedCompile ("javax:javaee-api:${java_ee_version}")
}
liberty {
server {
name = 'myServer'
apps = [file('build/libs/openliberty-jaxrs-example.war')]
dropins = [war]
stripVersion = true
}
install {
version = '17.0.0_03'
type = "microProfile1"
}
}
Improve integration with the installLiberty
task so that wlpDir
does not need to be set. For example, want to do something like:
liberty {
serverName = 'jaxrsSample'
userDir = '../async-jaxrs-wlpcfg'
install {
type = "javaee7"
}
}
And as long as installLiberty
task is called, rest of the tasks such as libertyStart
, etc. should work without any additional configuration.
Hi guys, I was wondering if is possible to add the ability to uninstall features from Gradle, currently only "install" is supported, so it would be awesome if we could uninstall features too.
I need to debug my server locally before pushing the code to production. I couldn't find in the documentation anything related to that.
Running the libertyRun
task prints this output:
libertyRun
This task can't be executed because some dependencies are missing
A quick look at the plugin source code reveals that the task catches the exception and does not log it to the output so I have no idea what is causing this error. See this catch block:
This should catch statement should fail the build and print the stack trace.
One of the dependencies for the plugin is a ws-server.jar which you can only get by downloading a copy of Liberty. This is different from the Liberty-Maven plugin and makes the installLiberty task useless since you need a copy of Liberty to get the plugin to let you run the installLiberty. You should be able to download the plugin without having a copy of Liberty and then download Liberty using the installLiberty task.
Calling the libertyStart task should invoke installLiberty, otherwise you have to add libertyStart.dependsOn('installLiberty') to the build.gradle file.
Steps to reproduce the problem
git clone https://github.com/WASdev/sample.servlet.git
//war {
// archiveName = baseName + '.' + extension
//}
liberty {
server {
bootstrapProperties = ['default.http.port': testServerHttpPort,
'default.https.port': testServerHttpsPort,
'appLocation': "${rootProject.name}-${version}.war",
'appContext': warContext]
name = wlpServerName
apps = [war]
stripVersion = false
}
}
build/wlp/usr/servers/LibertyProjectServer/configDropins/configDropins/defaults
directory.I guess the issue is caused by setting stripVersion=false
I found that in the gradle project is being used the gradle plugin "war" to do the deploy and undeploy of the applications and the use of this plugin is provoking a "false positive" when you call the "deployWar" without specify the params for the deploy.
The params are:
-destinationDir
-archiveName
I mean, my build file looks like this:
File: build.gradle
war{
destinationDir =file("resourcesToDeploy/")
archiveName = 'sample.war'
}
If you set those params there is not any problem, the result would be successful and the deploy of the application will be done.
But, if those params are not set in the build file the result of the "deployWar" task is also successful. Even if has not been specified any file to deploy, so, I added the following line in the "deployWar" task
just to see which file is being deployed:
File: Liberty.groovy
project.task('deployWar') {
doLast {
println 'File to deploy:' + project.war.archivePath
}
}
(archivePath is the result of concatenate "destinationDir " and "archiveName ") according to the "war" plugin documentation:
http://gradle.org/docs/current/dsl/org.gradle.api.tasks.bundling.War.html
If the parameters are not set:
File: build.gradle
war{
//destinationDir =file("resourcesToDeploy/")
//archiveName = 'sample.war'
}
The output (when the parameters weren't set) is this:
As you can see is looking for a war file with the same name of the project in a folder named "libs" which doesn't exist in my project.
The structure of my proyect is:
-GradlePractices
-resourcesToDeploy/
wlp-anttasks-1.1-SNAPSHOT.jar
liberty-gradle-plugin-1.0-SNAPSHOT.jar
build.gradle
Unlike in the Maven plugin where you can do:
<bootstrapProperties>
<default.http.port>${testServerHttpPort}</default.http.port>
<default.https.port>${testServerHttpsPort}</default.https.port>
</bootstrapProperties>
You can't specify bootstrap properties with the gradle plugin
Hi,
thanks for this plugin.
I hope to get help with following issue:
[ant:deploy] CWWKM2013I: Die validierte Datei C:\Apps\FIDE\wlp\usr\servers\defaultServer\logs\console.log ist nicht vorhanden.
It translates to:
CWWKM2013I: The file {0} being validated does not exist.
My gradle.build:
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'liberty'
repositories {
jcenter()
}
buildscript {
dependencies {
classpath files('C:\\Apps\\FIDE\\gradle-2.5\\wlp-plugin\\wlp-anttasks.jar')
classpath files('C:\\Apps\\FIDE\\gradle-2.5\\wlp-plugin\\liberty-gradle-plugin.jar')
classpath files('C:\\Apps\\FIDE\\wlp\\bin\\tools\\ws-server.jar')
}
}
liberty {
wlpDir = 'C:\\Apps\\FIDE\\wlp'
serverName = 'defaultServer'
deploy {
file = 'C:/Data/git/Experiments/Experiment/build/libs/Experiment.war'
}
packageLiberty{
archive = "MyServerPackage.zip"
include = "usr"
}
dumpLiberty{
archive = "C:/Temp/Dump.zip"
include = "heap, system"
}
javaDumpLiberty{
archive = "JavaDump.zip"
include = "system"
}
}
Best regards.
i think this is a gradle issue, but im putting it out here as well because im stuck and out of ideas
https://discuss.gradle.org/t/buildscript-classpath-in-multi-project-project/24535
does anyone know why this fails if you use a single build file in a multi-build project?
It's not possible to do have this in the build file:
libertyRun.dependsOn 'installLiberty'
and then run:
gradle libertyRun
Once you get past issue #46 you see that the issue is:
Caused by: java.lang.ClassNotFoundException: com.ibm.wsspi.kernel.embeddable.Ser
verBuilder
... 63 more
Basically, the libertyRun task expects the liberty runtime to be available in the buildscript
element so it has some Liberty classes available to it but that isn't the case if you are using the installLiberty task to install liberty.
Rename the wlpDir
parameter to installDir
. That will make it consistent with names in Liberty Ant tasks and the Liberty Maven plugin.
Create a clean task to delete logs, remove files in apps and dropins dir, etc. "OpenLiberty/ci.ant#26"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.