Open kdesineedi opened 9 years ago
What does it say when you do the gradlew clean insall -iS
?
Executing task ':projectname-core:install' (up-to-date check took 0.0 secs) due to: Task has not declared any outputs. [INFO] Installing projectname-core-0.1-SNAPSHOT.jar to F:\Project\0.1-SNAPSHOT\projectname-core-0.1-SNAPSHOT.jar :projectname-core:install (Thread[main,5,main]) completed. Took 0.114 secs.
I have 3 osgi bundles and one content package.The content package is installing when I tried the workaround you mentioned.But the other 3 bundles which were installed before the latest git changes are not being installed now.The above output is for one of the osgi bundles.It is the same for the other two as well.
I am running the gradlew clean install -iS at the parent folder which encompasses all the 3 osgi bundles and the one content package project.I see the osgi bundles getting generated under the build folder of each of the osgi projects and the zip file gets installed for the content package.The only problem is with the Osgi bundles.
Also I have applied the sling-plugin for the 3 osgi bundles and cqpackage for the content module and not vice versa.
That's caused by a conflict with the maven plugin
// remove "mvn install" since it's not needed and causes a conflict
def installTask = tasks.findByPath('install')
if (installTask != null) tasks.remove(installTask)
Hi Jim,
I do not have the install anymore in all of the modules.I have removed the apply plugin: 'maven' in all my build.gradle files but still the result is same.I am running by giving the command
gradlew clean install..Is there anything else I need to correct?
I realized that removing the apply-plugin:'maven' doesnt even invoke the install in the tasks list iS ouput.I have applied it back but still having the same issue
You have something overriding the install
task to copying it to F:\...
There's not anything in the sling-bundle
plugin that does anything like that. You need to see if you can identify what is taking over.
Thanks Jim.I will try to find it out. Can you please point me to the file which has those lines of code def installTask = tasks.findByPath('install') if (installTask != null) tasks.remove(installTask).?
I was not able to find it in the master branch by doing a file search.
BTW, the reason there's no provided
scope in this context is because (unless you're using a "fat jar" plugin) the dependencies aren't going to be packaged into the jar, so it doesn't serve a purpose. At the point where you are packaging dependencies you can exclude them from the configuration.
For example, when using the cqpackage
plugin you would do something like
configurations.cq_package {
exclude group: 'commons-io', module: 'commons-io'
}
to tell it what dependencies to not include when building the zip.
Is the below plugin required If I use the sling-plugin?
apply plugin: 'osgi'
Also does your plugin read anything in the existing pom.xml files of the project modules?
No file of the project has the tasks.remove(installTask)
snippet. I was suggesting you might want to add them to your build file after applying the maven plugin but before applying the sling-bundle plugin to disable the maven install task.
The maven
plugin isn't required for anything for sling-bundle
. You may have special needs for it, but generally it is best to stay away from it.
If you don't apply the osgi
plugin it will be done for you by sling-bundle
since it depends on it.
Now I have removed all other modules and ran a build for only one of the Osgi Bundles.Below is the (gradlew clean install -iS) output.Also it printed the list of tasks and there is only one install task.Can you please suggest any other way to debug this?
F:\projectname-core>gradlew clean install -iS Starting Build Settings evaluated using empty settings script. Projects loaded. Root project using build file 'F:\projectname-core\build.gradle'. Included projects: [root project 'projectname-core'] Evaluating root project 'projectname-core' using build file 'F:\projectname-core\build.gradle'. Compiling build file 'F:\projectname-core\build.gradle' using StatementExtractingScriptTransformer. Compiling build file 'F:\projectname-core\build.gradle' using BuildScriptTransformer. JSON environments file not passed in. Defaulting to localhost environment. All projects evaluated. Selected primary task 'clean' from project : Selected primary task 'install' from project : Tasks to be executed: [task ':clean', task ':compileJava', task ':processResources', task ':classes', task ':jar', task ':install'] :clean (Thread[main,5,main]) started. :clean Executing task ':clean' (up-to-date check took 0.001 secs) due to: Task has not declared any outputs. :clean UP-TO-DATE :clean (Thread[main,5,main]) completed. Took 0.054 secs. :compileJava (Thread[main,5,main]) started. :compileJava Executing task ':compileJava' (up-to-date check took 1.599 secs) due to: No history is available. All input files are considered out-of-date for incremental task ':compileJava'. Compiling with JDK Java compiler API. :compileJava (Thread[main,5,main]) completed. Took 2.54 secs. :processResources (Thread[main,5,main]) started. :processResources Executing task ':processResources' (up-to-date check took 0.005 secs) due to: No history is available. :processResources (Thread[main,5,main]) completed. Took 0.039 secs. :classes (Thread[main,5,main]) started. :classes Skipping task ':classes' as it has no actions. :classes (Thread[main,5,main]) completed. Took 0.012 secs. :jar (Thread[main,5,main]) started. :jar Executing task ':jar' (up-to-date check took 0.257 secs) due to: No history is available. :jar (Thread[main,5,main]) completed. Took 0.431 secs. :install (Thread[main,5,main]) started. :install Executing task ':install' (up-to-date check took 0.0 secs) due to: Task has not declared any outputs. Publishing configuration: configuration ':archives' Publishing to org.gradle.api.publication.maven.internal.ant.BaseMavenInstaller@7910f355 [INFO] Installing F:\projectname-core\build\libs\projectname-core-0.1-SNAPSHOT.jar to F:\MavenRepos\com\projectname\projectname-core :install (Thread[main,5,main]) completed. Took 0.434 secs.
BUILD SUCCESSFUL
Total time: 9.707 secs
Ok so I have come to a point where if I remove the apply plugin: 'maven' from build.gradle file the build fails with the message:
org.gradle.execution.TaskSelectionException: Task 'install' not found in root project 'projectname-core'.
So I am assuming all this while the install command is being executed from the maven plugin in the build.gradle file.So which task in the sling-bundle plugin should I be invoking now for executing the install command now?
My modified build.gradle file for the single Osgi module:
group = 'com.projectname' description = 'projectname Core' version = '0.1-SNAPSHOT'
buildscript { repositories { jcenter() maven { url "http://dl.bintray.com/twcable/aem" } }
dependencies {
classpath "com.twcable.gradle:cq-gradle-plugins:3.0.1"
}
}
allprojects {
repositories {
mavenLocal()
maven { url "http://repo.adobe.com/nexus/content/groups/public/" }
maven { url "http://repo.maven.apache.org/maven2" }
}
} configurations { provided compile.transitive = true }
apply plugin: 'java' apply plugin: 'osgi'
apply plugin: 'sling-bundle'
slingServers.author.installPath = '/apps/projectname/install' sourceCompatibility = 1.8 targetCompatibility = 1.8
dependencies { compile group: 'org.slf4j', name: 'slf4j-simple', version:'1.6.4' compile group: 'org.slf4j', name: 'slf4j-api', version:'1.6.6' compile group: 'org.apache.felix', name: 'org.osgi.core', version:'1.4.0' compile group: 'org.apache.felix', name: 'org.apache.felix.scr', version:'1.6.0' compile group: 'commons-collections', name: 'commons-collections', version:'3.0' compile group: 'commons-lang', name: 'commons-lang', version:'2.3' compile group: 'com.google.guava', name: 'guava', version:'14.0' compile(group: 'org.apache.felix', name: 'org.apache.felix.scr.annotations', version:'1.9.10') { /* This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'org.apache.felix', name: 'org.apache.felix.ipojo', version:'1.8.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'org.osgi', name: 'org.osgi.core', version:'4.2.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'javax.servlet', name: 'servlet-api', version:'2.5') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'javax.servlet', name: 'jsp-api', version:'2.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'com.adobe.aem', name: 'aem-api', version:'6.0.0.1') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'org.apache.sling', name: 'org.apache.sling.jcr.jcr-wrapper', version:'2.0.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. */ } compile(group: 'com.googlecode.jmockit', name: 'jmockit', version:'1.7') compile(group: 'junit', name: 'junit', version:'4.12') compile(group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version:'1.9.13')
}
uploadBundle{ }
showBundle { }
:panda_face: There is no install
task for sling-bundle
. However there is uploadBundle
...
oh ok.Now when I invoke the command gradlew uploadBundle,it fails with error:
Could not find id for com.projectname.core.I believe I need to change something in my config files to pass it on to the plugin?
It failed because the guava jar which gets embedded is missing in the plugin generated osgi bundle.How can I embed the missing jar to the generated osgi bundle?
"How can I embed the missing jar to the generated osgi bundle?"
Short answer: You don't. That's what the CQ Package Manager is for. Use the "cqpackage" plugin.
Longer answer: You can create a "fat jar", but the reasons for and against doing so, including how, are beyond scope...
FWIW, starting in AEM 6.0, Google Guava is included in AEM and will likely give you trouble unless you really know what you're doing. Use the v15 that AEM6 comes with.
oh ok.So if I use the cqpackage plugin the build fails stating that the contentSrc path is wrong since I do not have jcr_root like structure for this osGi bundle module.I have src/main/java and also I observed that OSGI-INF folder doesn't get generated.
You'd need at least some content if for nothing else than for the META-INF/vault
information.
OSGI-INF
doesn't get generated inside the bundle when you're using the scr
plugin?
When I apply the scr plugin here is the error:
Execution failed for task ':projectname-core:processScrAnnotations'.
java.lang.IllegalArgumentException (no error message)
Don't forget to run Gradle with the -iS
flag so you can see what's going on....
Sorry Jim,Yes I did do that but pasted only the topmost message.Here is the complete stack trace:
These are the plugins am using in that order:
apply plugin: 'java' apply plugin: 'scr' apply plugin: 'osgi' apply plugin: 'cqpackage' apply plugin: 'sling-bundle'
and also I had to create a dummy META-INF folder under the projectname-core/src/main/ in order to use the cqpackage plugin.Is there a way that I can indicate to the plugin that I am actually building a OSGI bundle and not a content package?
Also guava jar was an example but we would have more third party jars that would need to be embedded with the OSGI bundle in the future.Though we can remove the guava jar for now,we would probably end up having the same issue next time.
So currently I removed the guava dependency and trying to build an OSGI jar but it is failing with same error however the difference now is that I can see my projectname-core bundle in the OSGI bundle console.That is probably because it is uninstalling and then checking for the bundle.Please find below log:
Uninstalling com.projectname.core Removing com.projectname.core :projectname-core:uploadBundle FAILED :projectname-core:uploadBundle (Thread[main,5,main]) completed. Took 1.645 secs.
FAILURE: Build failed with an exception.
Problem getting bundle location from http://localhost:4502/system/console/bundles - 404:
So I invoked the showBundle task after the uploadbundle and here is the output:
{"status":"Bundle information: 435 bundles in total - all 435 bundles active.","s":[435,427,8,0,0],"data":[{"id":583,"name":"projectname-core","...............
"Is there a way that I can indicate to the plugin that I am actually building a OSGI bundle and not a content package?" Yes, don't include the 'cqpackage' plugin. Again, bundles and packages serve different purposes.
What command are you using to install the bundle? Just a simple ./gradlew uploadBundle
?
Yes Jim.
I am using gradlew uploadBundle -iS
Below is the list of plugins snippet from my build gradle file:
apply plugin: 'java' apply plugin: 'osgi' apply plugin: 'sling-bundle'
slingServers.author.installPath = '/apps/projectname/install' sourceCompatibility = 1.8 targetCompatibility = 1.8
..................................................... I am still getting a 404 and please find the trace of events leading to the error:I am not able to understand as to why after uninstalling bundle,the plugin searches for the projectname.core bundle and fails on execution.
Executing task ':projectname-core:uploadBundle' (up-to-date check took 0.001 secs) due to: Task has not declared any outputs. Uninstalling com.projectname.core Removing com.projectname.core :projectname-core:uploadBundle FAILED :projectname-core:uploadBundle (Thread[main,5,main]) completed. Took 1.626 secs.
FAILURE: Build failed with an exception.
Problem getting bundle location from http://localhost:4502/system/console/bundles - 404:
Just to level-set: This is happening with version '3.0.2' of the plugins?
So I changed it to classpath 'com.twcable.gradle:cq-gradle-plugins:3.0.2' and still the same error
And sometimes I get a build failure with while trying to upload the bundle generated in the build/libs folder.
Caused by: java.lang.IllegalStateException: Could not find id for com.projectName.core at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ......... at com.twcable.gradle.sling.osgi.SlingOsgiBundle.resetFelixId(SlingOsgiBundle.groovy:355) at com.twcable.gradle.sling.osgi.SlingOsgiBundle$resetFelixId$3.callCurrent(Unknown Source) at com.twcable.gradle.sling.osgi.SlingOsgiBundle.uploadBundle(SlingOsgiBundle.groovy:300) at com.twcable.gradle.sling.osgi.SlingOsgiBundle$uploadBundle$0.call(Unknown Source) at com.twcable.gradle.sling.osgi.SlingBundlePlugin$_uploadBundle_closure8_closure19_closure20.doCall(SlingBundlePlugin.groovy:172)
Is your bundle's id "com.projectName.core"? Are you setting it explicitly in MANIFEST.MF?
I am not setting it in MANIFEST explicitly.The plugin is generating it dynamically and in the generated MANIFEST I have the following: Bundle-SymbolicName: com.projectName.core. Is there another place I need to set this explicitly?
Hi Jim,
Now I am facing problems with the OsgI bundles.I am applying the plugin sling-bundle and issuing the gradlew clean install.
The Osgi bundle is getting generated locally in the build/libs folder of the project but nothing happens after that.Build is successful but the bundle doesn't get installed or even uploaded.
I am using the defaults except for the install path location.Am I invoking the plugin wrongly?
Please help.
Below is the build.gradle file I am using:
group = 'com.projectname' description = 'ProjectName Core' version = '0.1-SNAPSHOT'
configurations { provided compile.transitive = true }
apply plugin: 'java' apply plugin: 'maven' apply plugin: 'osgi' apply plugin: 'sling-bundle'
slingServers.author.installPath = '/apps/projectname/install'
sourceCompatibility = 1.8 targetCompatibility = 1.8
dependencies { compile group: 'org.slf4j', name: 'slf4j-simple', version:'1.6.4' compile group: 'org.slf4j', name: 'slf4j-api', version:'1.6.6' compile group: 'org.apache.felix', name: 'org.osgi.core', version:'1.4.0' compile group: 'org.apache.felix', name: 'org.apache.felix.scr', version:'1.6.0' compile group: 'commons-collections', name: 'commons-collections', version:'3.0' compile group: 'commons-lang', name: 'commons-lang', version:'2.3' compile group: 'com.google.guava', name: 'guava', version:'14.0' compile(group: 'org.apache.felix', name: 'org.apache.felix.scr.annotations', version:'1.9.10') { /* This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'org.apache.felix', name: 'org.apache.felix.ipojo', version:'1.8.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'org.osgi', name: 'org.osgi.core', version:'4.2.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'javax.servlet', name: 'servlet-api', version:'2.5') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'javax.servlet', name: 'jsp-api', version:'2.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'com.adobe.aem', name: 'aem-api', version:'6.0.0.1') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. / } compile(group: 'org.apache.sling', name: 'org.apache.sling.jcr.jcr-wrapper', version:'2.0.0') { / This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. */ } }
uploadBundle{ }
showBundle { }