Package au.net.ocean.maven.plugin.annotation

Examples of au.net.ocean.maven.plugin.annotation.Mojo


    }

    private MojoDescriptor extractMojo(Class<?> clazz) throws InvalidPluginDescriptorException {
        getLogger().debug("scanning class: " + clazz.getName());
        MojoDescriptor mojoDescriptor = null;
        Mojo mojo = clazz.getAnnotation(Mojo.class);
        if (mojo != null) {
            getLogger().info("found @Mojo in: " + clazz.getName());
            mojoDescriptor = new MojoDescriptor();
            mojoDescriptor.setLanguage("java");
            mojoDescriptor.setImplementation(clazz.getName());
            mojoDescriptor.setDescription(mojo.description().trim());
            mojoDescriptor.setInstantiationStrategy(mojo.instantiationStrategy().value);
            mojoDescriptor.setExecutionStrategy(mojo.executionStrategy().value);
            String configurator = clazz.getAnnotation(Mojo.class).configurator();
            if (configurator.trim().length() > 0) {
                mojoDescriptor.setComponentConfigurator(configurator.trim());
            }
            mojoDescriptor.setGoal(clazz.getAnnotation(Mojo.class).goal().trim());
            mojoDescriptor.setPhase(mojo.phase().value);
            Execution execute = mojo.execute();
            String lifecycle = execute.lifecycle().trim().length() == 0 ? null : execute.lifecycle().trim();
            String goal = execute.goal().trim().length() == 0 ? null : execute.goal().trim();
            Phase phase = execute.phase();
            if (goal != null || phase != Phase.None) {
                if (goal != null) {
                    if (lifecycle != null) {
                        throw new InvalidPluginDescriptorException("'goal' cannot be specified with 'lifecycle' in execute annotation");
                    }
                    if (phase != Phase.None) {
                        throw new InvalidPluginDescriptorException("execute annotation cannot specify both 'phase' and 'goal'");
                    }
                    mojoDescriptor.setExecuteGoal(goal);
                } else {
                    mojoDescriptor.setExecutePhase(phase.value);
                    if (lifecycle != null) {
                        mojoDescriptor.setExecuteLifecycle(lifecycle);
                    }
                }
            }
            mojoDescriptor.setDependencyResolutionRequired(mojo.requiresDependencyResolution().value);
            mojoDescriptor.setProjectRequired(mojo.requiresProject());
            mojoDescriptor.setAggregator(mojo.aggregator());
            mojoDescriptor.setDirectInvocationOnly(mojo.requiresDirectInvocation());
            mojoDescriptor.setOnlineRequired(mojo.requiresOnline());
            mojoDescriptor.setInheritedByDefault(mojo.inheritByDefault());
            if (mojo.deprecated().trim().length() > 0) {
                mojoDescriptor.setDeprecated(mojo.deprecated());
            }
            // extract parameters working back through the inheritancce hierarchy
            while (!clazz.equals(Object.class)) {
                for (Field field : clazz.getDeclaredFields()) {
                    org.apache.maven.plugin.descriptor.Parameter parameter = extractParameter(field);
View Full Code Here


    public MojoConfigurationException(OceanMojo mojo, List<String> configErrors) {
        super(errorMessage(mojo, configErrors));
    }

    private static String errorMessage(OceanMojo mojo, List<String> configErrors) {
        Mojo mojoAnnotation = mojo.getClass().getAnnotation(Mojo.class);

        StringBuilder errorMessage = new StringBuilder("One or more required plugin parameters are invalid/missing for '")
                .append(mojo.getPrefix()).append(':').append(mojoAnnotation.goal()).append("'\n\n");
        for (String error : configErrors) {
            errorMessage.append(error).append("\n");
        }
        return errorMessage.toString();
    }
View Full Code Here

    }

    private MojoDescriptor extractMojo(Class<?> clazz) throws InvalidPluginDescriptorException {
        getLogger().debug("scanning class: " + clazz.getName());
        MojoDescriptor mojoDescriptor = null;
        Mojo mojo = clazz.getAnnotation(Mojo.class);
        if (mojo != null) {
            getLogger().info("found @Mojo in: " + clazz.getName());
            mojoDescriptor = new MojoDescriptor();
            mojoDescriptor.setLanguage("java");
            mojoDescriptor.setImplementation(clazz.getName());
            mojoDescriptor.setDescription(mojo.description().trim());
            mojoDescriptor.setInstantiationStrategy(mojo.instantiationStrategy().value);
            mojoDescriptor.setExecutionStrategy(mojo.executionStrategy().value);
            String configurator = clazz.getAnnotation(Mojo.class).configurator();
            if (configurator.trim().length() > 0) {
                mojoDescriptor.setComponentConfigurator(configurator.trim());
            }
            mojoDescriptor.setGoal(clazz.getAnnotation(Mojo.class).goal().trim());
            mojoDescriptor.setPhase(mojo.phase().value);
            Execution execute = mojo.execute();
            String lifecycle = execute.lifecycle().trim().length() == 0 ? null : execute.lifecycle().trim();
            String goal = execute.goal().trim().length() == 0 ? null : execute.goal().trim();
            Phase phase = execute.phase();
            if (goal != null || phase != Phase.None) {
                if (goal != null) {
                    if (lifecycle != null) {
                        throw new InvalidPluginDescriptorException("'goal' cannot be specified with 'lifecycle' in execute annotation");
                    }
                    if (phase != Phase.None) {
                        throw new InvalidPluginDescriptorException("execute annotation cannot specify both 'phase' and 'goal'");
                    }
                    mojoDescriptor.setExecuteGoal(goal);
                } else {
                    mojoDescriptor.setExecutePhase(phase.value);
                    if (lifecycle != null) {
                        mojoDescriptor.setExecuteLifecycle(lifecycle);
                    }
                }
            }
            mojoDescriptor.setDependencyResolutionRequired(mojo.requiresDependencyResolution().value);
            mojoDescriptor.setProjectRequired(mojo.requiresProject());
            mojoDescriptor.setAggregator(mojo.aggregator());
            mojoDescriptor.setDirectInvocationOnly(mojo.requiresDirectInvocation());
            mojoDescriptor.setOnlineRequired(mojo.requiresOnline());
            mojoDescriptor.setInheritedByDefault(mojo.inheritByDefault());
            if (mojo.deprecated().trim().length() > 0) {
                mojoDescriptor.setDeprecated(mojo.deprecated());
            }
            // extract parameters working back through the inheritance hierarchy
            while (!clazz.equals(Object.class)) {
                for (Field field : clazz.getDeclaredFields()) {
                    org.apache.maven.plugin.descriptor.Parameter parameter = extractParameter(field);
View Full Code Here

TOP

Related Classes of au.net.ocean.maven.plugin.annotation.Mojo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.