public void execute()

in buildutils/axiom-weaver-maven-plugin/src/main/java/org/apache/axiom/weaver/maven/WeaveMojo.java [63:117]


    public void execute() throws MojoExecutionException, MojoFailureException {
        Log log = getLog();
        URLClassLoader classLoader = createClassLoader();
        try {
            Weaver weaver =
                    new Weaver(
                            classLoader,
                            (iface) -> {
                                String packageName = iface.getPackage().getName();
                                for (PackageMapping packageMapping : packageMappings) {
                                    if (packageName.equals(packageMapping.getInterfacePackage())) {
                                        return packageMapping.getOutputPackage()
                                                + "."
                                                + iface.getSimpleName()
                                                + "Impl";
                                    }
                                }
                                throw new WeaverException(
                                        "No package mapping defined for package " + packageName);
                            });
            for (String packageName : weavablePackages) {
                weaver.loadWeavablePackage(packageName);
            }
            for (String interfaceName : interfaces) {
                try {
                    weaver.addInterfaceToImplement(classLoader.loadClass(interfaceName));
                } catch (ClassNotFoundException ex) {
                    throw new MojoFailureException("Failed to load class " + interfaceName, ex);
                }
            }
            for (ClassDefinition classDefinition : weaver.generate()) {
                File outputFile =
                        new File(
                                project.getBuild().getOutputDirectory(),
                                classDefinition.getClassName() + ".class");
                if (log.isDebugEnabled()) {
                    StringWriter sw = new StringWriter();
                    classDefinition.dump(new PrintWriter(sw));
                    log.debug(String.format("Generating %s:\n%s", outputFile, sw));
                }
                outputFile.getParentFile().mkdirs();
                try (FileOutputStream out = new FileOutputStream(outputFile)) {
                    out.write(classDefinition.toByteArray());
                } catch (IOException ex) {
                    throw new MojoFailureException("Unable to write " + outputFile, ex);
                }
            }
        } finally {
            try {
                classLoader.close();
            } catch (IOException ex) {
                log.warn(ex);
            }
        }
    }