As far as I know Goethe has that title with Faust (this site tells that it spanned 57 years).
So, is it the record; or are there any other works took longer? Unfinished works are also considered to be included in the scope of question.
The problem with the question is: how do you determine how long it took an author to finish a work of literature? Do you just look at the years between the first draft and the final publication or at the years during which the author effectively worked on the book?
For example, the earliest drafts of Goethe's Faust, also known as Urfaust, probably date from the years 1772 - 1775. Faust, a Fragment was published in 1790. Faust, Part One was published in 1808; Faust, Part Two followed in 1831. There are 59 years between 1772 and 1831, but almost all of Goethe's other works were written between those years. It is clear that Goethe did not continuously work on Faust. Also, in addition to his work as an author, he was a member of the privy council of Duke Karl August of Saxe-Weimar. Goethe definitely did not dedicate 57 or 59 years of his life to Faust.
A better example would be James Joyce's Finnegans Wake, which took the author seventeen years to write. Joyce did not publish any other fiction during this period.
If non-fiction can be accepted, another example would be Montaigne's Essays. Though first published in 1580, Montaigne worked on them during a period of twenty years ("from approximately 1570 to 1592" according to Wikipedia) and did not publish anything else during that period. Some editions mark the changes Montaigne made to earlier essays, for example as follows (according to [Wikipedia](from approximately 1570 to 1592)):
If diaries can count as works of literature, it is easy to find works that span a much longer period of time:
Tolkien's Silmarillion is probably a contender. According to the Tolkien Society's timeline, his first identifiable Middle-Earth fragment (which would likely have been part of his 'Lost Tales', which are a proto-Silmarillion) was written in 1914. Tolkien died in 1973, with the Silmarillion still unfinished; it was edited and published posthumously by Christopher Tolkien. This gives us a total of 59 years.
For the record, another source cites Ezra Pound's The Cantos as taking 57 years to write.
Also, depending on how you define 'book', the Bible as a whole took several thousand years [out of God's life? now you see the difficulty with the question]. Similar is probably true for some other religious texts.
Another interesting statistic could be words/day - for example, the Silmarillion (as posthumously published) has ~130k words; this comes out to 6.03 words per day. However, books like Catcher in the Rye were written at a rate of ~10 words per day (10 years to write, but it's a very short book) - so it's another interesting statistic.
Yet another interesting statistic could be percentage of the author's life - e.g., Tolkien was 81 when he died, meaning he spent ~73% of his life working on the Silmarillion (though Christophe Strobbe's answer is excellent in pointing out that it is unlikely that this time is continuously spent working on it). Goethe's Faust, for comparison, took ~70% of the author's life - he died at 82.
(For the record, I think it's probably going to be very difficult to get a definitive answer on this question.)