who was the first to composed law books in sri lanka
The Anuradhapura Kingdom.
Anuradhapura Kingdom
The Anuradhapura Kingdom (Sinhala: , translit: Anurādhapura Rājadhāniya, Tamil: ), named for its capital city, was the first established kingdom in ancient Sri Lanka and Sinhalese people. Founded by King Pandukabhaya in 377 BC, the kingdom's authority extended throughout the country, although several independent areas emerged from time to time, which grew more numerous towards the end of the kingdom. Nonetheless, the king of Anuradhapura was seen as the supreme ruler of the country throughout the Anuradhapura period. Buddhism played a strong role in the Anuradhapura period, influencing its culture, laws, and methods of governance. Society and culture were revolutionized when the faith was introduced during the reign of King Devanampiya Tissa; this cultural change was further strengthened by the arrival of the Tooth Relic of the Buddha in Sri Lanka and the patronage extended by her rulers.

wiki:24614803
Anuradhapura Kingdom [SEP] Introduction
The Anuradhapura Kingdom (Sinhala: , translit: Anurādhapura Rājadhāniya, Tamil: ), named for its capital city, was the first established kingdom in ancient Sri Lanka and Sinhalese people. Founded by King Pandukabhaya in 377 BC, the kingdom's authority extended throughout the country, although several independent areas emerged from time to time, which grew more numerous towards the end of the kingdom. Nonetheless, the king of Anuradhapura was seen as the supreme ruler of the country throughout the Anuradhapura period. Buddhism played a strong role in the Anuradhapura period, influencing its culture, laws, and methods of governance. Society and culture were revolutionized when the faith was introduced during the reign of King Devanampiya Tissa; this cultural change was further strengthened by the arrival of the Tooth Relic of the Buddha in Sri Lanka and the patronage extended by her rulers.