Cannot access compiled protobuf java class from one project in src/test of another project

Actually, from reading what you wrote this sounds like a strange setup.
Shouldn’t A build source source files into class files, by having something like

sourceSets { 
    main {
        java {
            srcDir(theTaskGeneratingTheJavaSources)
        }
    }
}

and then B just normally depending on A not needing to reach into the other project to take source files from there?