Automating component reuse and adaptation