Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help required for the deploy the Osgi Bundles #27

Open
kdesineedi opened this issue Aug 17, 2015 · 32 comments
Open

Help required for the deploy the Osgi Bundles #27

kdesineedi opened this issue Aug 17, 2015 · 32 comments

Comments

@kdesineedi
Copy link

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 {
}

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

What does it say when you do the gradlew clean insall -iS?

@kdesineedi
Copy link
Author

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.

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

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)

@kdesineedi
Copy link
Author

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?

@kdesineedi
Copy link
Author

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

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

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.

@kdesineedi
Copy link
Author

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.

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

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.

@kdesineedi
Copy link
Author

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?

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

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.

@kdesineedi
Copy link
Author

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

@kdesineedi
Copy link
Author

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 {
}

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

🐼 There is no install task for sling-bundle. However there is uploadBundle...

@kdesineedi
Copy link
Author

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?

@kdesineedi
Copy link
Author

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?

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

"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...

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

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.

@kdesineedi
Copy link
Author

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.

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

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?

@kdesineedi
Copy link
Author

When I apply the scr plugin here is the error:

Execution failed for task ':projectname-core:processScrAnnotations'.

java.lang.IllegalArgumentException (no error message)

@jdigger
Copy link
Member

jdigger commented Aug 17, 2015

Don't forget to run Gradle with the -iS flag so you can see what's going on....

@kdesineedi
Copy link
Author

Sorry Jim,Yes I did do that but pasted only the topmost message.Here is the complete stack trace:

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':projectname-core:processScrAnnotations'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.jav
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    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:497)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    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:497)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
    Caused by: java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.(Unknown Source)
    at org.objectweb.asm.ClassReader.(Unknown Source)
    at org.objectweb.asm.ClassReader.(Unknown Source)
    at org.apache.felix.scrplugin.helper.ClassScanner.processClass(ClassScanner.java:172)
    at org.apache.felix.scrplugin.helper.ClassScanner.scanSources(ClassScanner.java:143)
    at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(SCRDescriptorGenerator.java:149)
    at org.apache.felix.scrplugin.ant.SCRDescriptorTask.execute(SCRDescriptorTask.java:129)
    at org.apache.felix.scrplugin.ant.SCRDescriptorTask$execute.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at com.twcable.gradle.scr.ScrPlugin.configureAction(ScrPlugin.groovy:77)
    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:497)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:368)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:807)
    at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:355)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at com.twcable.gradle.scr.ScrPlugin$_addScrTask_closure1_closure4.doCall(ScrPlugin.groovy:59)
    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:497)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    at groovy.lang.Closure.call(Closure.java:423)
    at groovy.lang.Closure.call(Closure.java:439)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:548)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:529)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 55 more

@kdesineedi
Copy link
Author

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.

@kdesineedi
Copy link
Author

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.

@kdesineedi
Copy link
Author

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","...............

@jdigger
Copy link
Member

jdigger commented Aug 20, 2015

"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?

@kdesineedi
Copy link
Author

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.

@jdigger
Copy link
Member

jdigger commented Aug 21, 2015

Just to level-set: This is happening with version '3.0.2' of the plugins?

@kdesineedi
Copy link
Author

So I changed it to classpath 'com.twcable.gradle:cq-gradle-plugins:3.0.2' and still the same error

@kdesineedi
Copy link
Author

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)

@jdigger
Copy link
Member

jdigger commented Aug 21, 2015

Is your bundle's id "com.projectName.core"? Are you setting it explicitly in MANIFEST.MF?

@kdesineedi
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants