What is the order of precedence when a property is set using convention mapping?

For example, ‘JavaBasePlugin’ has the following code

project.getTasks().withType(AbstractCompile.class, new Action<AbstractCompile>() {
            public void execute(final AbstractCompile compile) {
                ConventionMapping conventionMapping = compile.getConventionMapping();
                conventionMapping.map("sourceCompatibility", new Callable<Object>() {
                    public Object call() throws Exception {
                        return javaConvention.getSourceCompatibility().toString();
                    }
                });
                conventionMapping.map("targetCompatibility", new Callable<Object>() {
                    public Object call() throws Exception {
                        return javaConvention.getTargetCompatibility().toString();
                    }
                });
            }
        });

Which value wins if a build explicitly sets the value? e.g. if one were to do the following.

project.tasks.withType(AbstractCompile, { it.sourceCompatibility = someValue } )

Use case is that I have someone who wants to compile 1 sourceset with java7 and another with java6.

The purpose of convention mapping is to provide (lazy) defaults. As soon as a property is set explicitly, convention mapping will no longer kick in.

can conventions be overridden? i.e. if I set another convention mapping does the last one set win?

I also notice ‘MappedProperty’ has a cached method which causes the value to not be re evaluated. How should one use this? After declaration of the mapping?

Yes, they can be overridden, though it wouldn’t typically be necessary. You probably shouldn’t use the ‘cached’ method. I didn’t even know it exists.

OK so if multiple things want to set a default on something then there is no way to manage the conflict or be aware of the conflict apart from looking through the src code, is that correct?

That’s correct. Setting default values (esp. via convention mapping) is the responsibility of the plugin that adds the domain object to the domain model.