All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mini2Dx.gettext.plugin.GetTextPlugin.groovy Maven / Gradle / Ivy

There is a newer version: 1.11.0
Show newest version
/*******************************************************************************
 * Copyright 2019 Thomas Cashman
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package org.mini2Dx.gettext.plugin

import org.gradle.api.*
import org.mini2Dx.gettext.plugin.task.GeneratePotTask

class GetTextPlugin implements Plugin {
    final List potTaskNames = new ArrayList();

    @Override
    void apply(Project project) {
        NamedDomainObjectContainer sourceContainer = project.container(GetTextSource.class, new NamedDomainObjectFactory() {
            public GetTextSource create(String name) {
                return new GetTextSource(name);
            }
        });

        project.getExtensions().add("gettext", sourceContainer);

        sourceContainer.all(new Action() {
            @Override
            void execute(GetTextSource getTextSource) {
                final String sourceType = getTextSource.getName();
                final String capitalizedSourceType = sourceType.substring(0, 1).toUpperCase() + sourceType.substring(1);
                final String taskName = "generatePot" + capitalizedSourceType;
                potTaskNames.add(taskName);

                project.getTasks().register(taskName, GeneratePotTask.class, new Action() {
                    public void execute(GeneratePotTask task) {
                        task.source = getTextSource;
                    }
                });
            }
        });
        project.getTasks().register("generatePots").configure {
            setDependsOn(potTaskNames)
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy