Importing Bazel built ONOS 1.14 or higher into Intellij

486 views
Skip to first unread message

Andrea Campanella

unread,
Aug 24, 2018, 6:03:44 AM8/24/18
to ONOS Developers, ONOS Discuss
Hi ONOS developers,

As you know since ONOS version 1.14 the ONOS project moved to Bazel and the use of BUILD files. In version 1.15 (current Master) we have already dropped completely the pom.xml files from the codebase. 

For you to develop using Intellij and the newest version of ONOS we wrote a page on how to import a Bazel based project into the IDE. You can find it here:

For more information about Bazel and how to Build ONOS with it please visit the wiki (wiki.onosproject.org) or follow the TST meeting:

I hope this helps you and empowers you to continuously create new great ONOS code and use cases. 

Please do not hesitate to try all of this out and ask any question you might have.

Looking forward to your contributions,
Happy coding! 
Andrea Campanella

Member of Technical Staff at ONF
Member of ONOS Technical Steering Team
Member of Ambassador Steering Team, ONOS and CORD Community

sean.condon

unread,
Aug 24, 2018, 9:24:06 AM8/24/18
to ONOS Developers, onos-d...@onosproject.org
Great notes - Thanks. And great to see the end of the pom.xml files.

I couldn't find anything on the Wiki that says the Bazel version has to be 15.2 though, like Thomas had in his original mail at


Andrea Campanella

unread,
Aug 24, 2018, 11:09:06 AM8/24/18
to sean.condon, ONOS Developers, onos-d...@onosproject.org
Hi Sean,

Thanks for pointing that out. I’ve updated the wiki here

With a warning to specify bazel 0.15.2.

Thanks,
Andrea Campanella

Member of Technical Staff at ONF
Member of ONOS Technical Steering Team
Member of Ambassador Steering Team, ONOS and CORD Community

--
You received this message because you are subscribed to the Google Groups "ONOS Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+u...@onosproject.org.
To post to this group, send email to onos...@onosproject.org.
Visit this group at https://groups.google.com/a/onosproject.org/group/onos-dev/.
To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/onos-dev/e3d8a01d-a9d1-4217-8a00-ca06d0002605%40onosproject.org.

Georgios Katsikas

unread,
Aug 24, 2018, 12:48:54 PM8/24/18
to Andrea Campanella, sean....@microchip.com, ONOS Developers, onos-d...@onosproject.org
Hi Andrea,

Thanks for the great tutorial, much appreciated!
Could you please add one more sentence on how to clean before a build?
With BUCK this was: rm -rf buck-out bin && onos-buck clean.
What is the Bazel counterpart of this command?

Thanks,
Georgios



--
   Georgios Katsikas
   Industrial Ph.D. Student
   Network Systems Lab (NSL)

   

       E-Mail: kats...@kth.se
   Web Site: https://www.kth.se/profile/katsikas/

Ray Milkey

unread,
Aug 24, 2018, 12:53:54 PM8/24/18
to kats...@kth.se, Andrea Campanella, sean....@microchip.com, onos...@onosproject.org, ONOS Discuss
Great idea! To completely clean your bazel caches and restart the bazel server, you can use:

bazel clean --expunge

In my experience with bazel, it does an excellent job of tracking dependencies and cleans are rarely needed. I did have to do them a few times while developing new rules, before all of the dependencies are right.


You received this message because you are subscribed to the Google Groups "ONOS Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onos-discuss...@onosproject.org.
To post to this group, send email to onos-d...@onosproject.org.
Visit this group at https://groups.google.com/a/onosproject.org/group/onos-discuss/.
To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/onos-discuss/CAN9HtFC9c7B9cRSwATDs5qwSdK9TTUTHJiYsOMj2U06e%2B%3DcHYg%40mail.gmail.com.

Georgios Katsikas

unread,
Aug 24, 2018, 12:56:08 PM8/24/18
to Ray Milkey, Andrea Campanella, sean....@microchip.com, ONOS Developers, onos-d...@onosproject.org
Hi Ray,

Thanks a lot!

Best regards,
Georgios

Debobroto Das

unread,
Feb 3, 2020, 5:36:39 PM2/3/20
to ONOS Developers, onos-d...@onosproject.org
Hello everyone,

After importing the onos codebase to intellij as a bazel project, there is a problem with which folder should be the sources root. Can anyone please tell  me that? 
Otherwise it is showing package name does not correspond to file path. Though I have imported the setting from onos/tools/dev/ideasettings.jar

Carmelo Cascone

unread,
Feb 4, 2020, 1:36:07 PM2/4/20
to Debobroto Das, ONOS Developers, onos-d...@onosproject.org
Source directories should be automatically derived form the bazel targets declared in the .bazelproject file.

have already followed the steps in this page to automatically generate a .bazelproject file?

— Carmelo

--
You received this message because you are subscribed to the Google Groups "ONOS Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onos-discuss...@onosproject.org.

Debobroto Das

unread,
Feb 4, 2020, 1:52:07 PM2/4/20
to ONOS Developers, debobrot...@gmail.com, onos-d...@onosproject.org
I have followed this steps described on the link. But not working. Tried to sync the bazel project with bazel files and it shows several errors. but bazel build succeeds and onos runs perfectly. 

first error is 

ERROR: /home/deba/p4-guide/onos/BUILD:133:11: in cmd attribute of genrule rule //:onos-local_absolute-javabase: $(ABSOLUTE_JAVABASE) not defined
 

I am using java 11. I have imported the onos project successfully according to the steps earlier. But this time, its not working. 
To unsubscribe from this group and stop receiving emails from it, send an email to onos-d...@onosproject.org.

Debobroto Das

unread,
Feb 4, 2020, 2:03:03 PM2/4/20
to ONOS Developers, debobrot...@gmail.com, onos-d...@onosproject.org
I have setup the java_base in the bazelrc file. that solved the first problem of java_base but I have no clue about the rest of the problems. 
While trying to sync the project with bazel file I am getting error of following type

ERROR: /home/deba/p4-guide/onos/providers/lldp/BUILD:10:1: Couldn't build file providers/lldp/onos-providers-lldp-native.java-manifest: Parsing java package strings for //providers/lldp:onos-providers-lldp-native failed (Exit 1) PackageParser_bin failed: error executing command bazel-out/host/bin/external/intellij_aspect/PackageParser_bin --output_manifest bazel-out/k8-fastbuild/bin/providers/lldp/onos-providers-lldp-native.java-manifest --sources ... (remaining 1 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
Feb 04, 2020 2:00:57 PM com.google.idea.blaze.aspect.PackageParser main
SEVERE: Error parsing package strings
java.lang.NoClassDefFoundError: com/google/common/util/concurrent/internal/InternalFutureFailureAccess
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.google.common.util.concurrent.AbstractListeningExecutorService.newTaskFor(AbstractListeningExecutorService.java:51)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:139)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:66)
at com.google.idea.blaze.aspect.PackageParser.parsePackageStrings(PackageParser.java:139)
at com.google.idea.blaze.aspect.PackageParser.main(PackageParser.java:77)
Caused by: java.lang.ClassNotFoundException: com.google.common.util.concurrent.internal.InternalFutureFailureAccess
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 50 more

Mainak Majumder

unread,
Feb 5, 2020, 3:10:54 AM2/5/20
to ONOS Developers, debobrot...@gmail.com, onos-d...@onosproject.org
Hi,

i think this error is caused either by the new Intellij IDE or the bazel plugin. I had the same problem while importing the project. I am using v2019.2.4 of Intellij IDE and bazel plugin 2019.10.14.0.0. It worked for me.  

Message has been deleted

Hadi Kahraman

unread,
Feb 5, 2020, 5:39:23 AM2/5/20
to Mainak Majumder, ONOS Developers, debobrot...@gmail.com, ONOS Discuss
From my notes for ONOS 1.15:

Install IntelliJ idea-IC-183.6156.11, *** 2018.3, NOT THE LATEST VERSION***
Install "Bazel" plugin to Idea: file -> settings -> plugins

Mainak Majumder <mainakma...@gmail.com>, 5 Şub 2020 Çar, 11:10 tarihinde şunu yazdı:
You received this message because you are subscribed to the Google Groups "ONOS Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+u...@onosproject.org.
To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/onos-dev/c469bf85-8ecf-4955-ba5b-41b217d60f51%40onosproject.org.

Hadi Kahraman

unread,
Feb 5, 2020, 5:44:30 AM2/5/20
to Mainak Majumder, ONOS Developers, debobrot...@gmail.com, ONOS Discuss
And:

Install bazel 0.23.2, *** NOT THE LATEST VERSION***

Hadi Kahraman <hadi.k...@gmail.com>, 5 Şub 2020 Çar, 13:39 tarihinde şunu yazdı:
Message has been deleted

jkkr

unread,
May 18, 2022, 1:56:01 AM5/18/22
to ONOS Discuss, Debobroto Das, onos-d...@onosproject.org, ONOS Developers
Hi, 

I have same problem with you. When I 'expand synch to working set' , I get the error "ERROR: /home/jku/onos/BUILD:138:8: in cmd attribute of genrule rule //:onos-local_absolute-javabase: $(ABSOLUTE_JAVABASE) not defined".  And when not expanding to working set, It is synced with no problem.

Can you tell me how you setup javabase in bazelrc file ? 
I really want to get through this stuff. I googled a lot, and only solution I found was yours 

Please share your java_base solution to me~ 
Thanks for reading 

Best,
Jkkr


2020년 2월 5일 수요일 오전 3시 52분 11초 UTC+9에 Debobroto Das님이 작성:
Reply all
Reply to author
Forward
0 new messages