#NEWLINE# def test_protos_extracted_under_build_root( self ) : #NEWLINE# #INDENT# 'This testcase shows that you can put sources for protos outside the directory where the\n    BUILD file is defined. This will be the case for .proto files that have been extracted\n    under .pants.d.\n    ' #NEWLINE# extracted_source_path = os . path . join ( self . build_root , 'extracted' , 'src' , 'proto' ) #NEWLINE# sample_proto_path = os . path . join ( extracted_source_path , 'sample-package' , 'sample.proto' ) #NEWLINE# self . create_file ( sample_proto_path , dedent ( '\n          package com.example;\n          message sample {}\n        ' ) ) #NEWLINE# self . add_to_build_file ( 'sample' , dedent ( "\n        jar_library(name='jar',\n          jars=[jar('org.example', 'jar', '0.0.1')]\n        )" ) . format ( sample_proto_path = sample_proto_path ) ) #NEWLINE# self . add_to_build_file ( 'sample' , dedent ( "\n        java_protobuf_library(name='sample',\n          sources=from_target(':jar'),\n        )" ) . format ( sample_proto_path = sample_proto_path ) ) #NEWLINE# target = self . target ( 'sample:sample' ) #NEWLINE# target . payload . sources . populate ( [ sample_proto_path ] , extracted_source_path ) #NEWLINE# context = self . context ( target_roots = [ target ] ) #NEWLINE# task = self . create_task ( context = context ) #NEWLINE# sources_by_base = task . _calculate_sources ( target ) #NEWLINE# self . assertEquals ( [ 'extracted/src/proto' ] , sources_by_base . keys ( ) ) #NEWLINE# self . assertEquals ( OrderedSet ( [ sample_proto_path ] ) , sources_by_base [ 'extracted/src/proto' ] )