void generatePropertiesFile(@NotNull Properties properties, File base, String propertiesFilename)
      throws IOException {
    FileWriter fileWriter = null;
    File gitPropsFile = new File(base, propertiesFilename);
    try {
      Files.createParentDirs(gitPropsFile);

      fileWriter = new FileWriter(gitPropsFile);
      if ("json".equalsIgnoreCase(format)) {
        log(
            "Writing json file to [",
            gitPropsFile.getAbsolutePath(),
            "] (for module ",
            project.getName() + (++counter),
            ")...");
        ObjectMapper mapper = new ObjectMapper();
        mapper.writeValue(fileWriter, properties);
      } else {
        log(
            "Writing properties file to [",
            gitPropsFile.getAbsolutePath(),
            "] (for module ",
            project.getName() + (++counter),
            ")...");
        properties.store(fileWriter, "Generated by Git-Commit-Id-Plugin");
      }

    } catch (IOException ex) {
      throw new RuntimeException("Cannot create custom git properties file: " + gitPropsFile, ex);
    } finally {
      Closeables.closeQuietly(fileWriter);
    }
  }
  /** Check if a project is excluded based on its artifactId or a parent's artifactId */
  protected boolean isExcluded(MavenProject mavenProject, String rootArtifactId) {
    final Log logger = this.getLog();

    final String artifactId = mavenProject.getArtifactId();
    if (this.excludedModules.contains(artifactId)) {
      logger.info(
          "Skipping aggregation of child module "
              + mavenProject.getName()
              + " with excluded artifactId: "
              + artifactId);
      return true;
    }

    MavenProject parentProject = mavenProject.getParent();
    while (parentProject != null && !rootArtifactId.equals(parentProject.getArtifactId())) {
      final String parentArtifactId = parentProject.getArtifactId();
      if (this.excludedModules.contains(parentArtifactId)) {
        logger.info(
            "Skipping aggregation of child module "
                + mavenProject.getName()
                + " with excluded parent artifactId: "
                + parentArtifactId);
        return true;
      }
      parentProject = parentProject.getParent();
    }

    return false;
  }
 public void execute() throws MojoExecutionException {
   Log log = getLog();
   if (skip) {
     log.debug("Skipping collection of artifacts");
     return;
   }
   File targetDirectoryFile = new File(targetDirectoryName);
   File outputDir;
   if (targetDirectoryFile.isAbsolute()) {
     outputDir = targetDirectoryFile;
     if (!outputDir.exists()) {
       throw new MojoExecutionException(
           "Specified targetDirectoryName " + targetDirectoryName + " doesn't exists");
     }
     if (!outputDir.isDirectory()) {
       throw new MojoExecutionException(
           "Specified targetDirectoryName " + targetDirectoryName + " is not a directory");
     }
   } else {
     MavenProject parent = getParent(project);
     while (parent != null) {
       MavenProject tmp = getParent(parent);
       if (tmp == null) {
         break;
       }
       parent = tmp;
     }
     if (parent == null) {
       log.debug("Parent not found, nothing to do");
       return;
     }
     outputDir = new File(parent.getBuild().getDirectory(), targetDirectoryName);
     log.debug("Found parent " + parent.getName() + ", output dir: " + outputDir);
   }
   if (project.getPackaging().equals(targetPackaging)) {
     log.debug("Found requested artifact for project " + project.getName());
     try {
       FileUtils.mkdir(outputDir.getCanonicalPath());
     } catch (IOException e) {
       throw new MojoExecutionException(
           "Unable to create directory " + outputDir.getAbsolutePath(), e);
     }
     File artifactFile = project.getArtifact().getFile();
     File destination = new File(outputDir, artifactFile.getName());
     try {
       log.info(
           "Copying artifact "
               + artifactFile.getCanonicalPath()
               + " to "
               + destination.getCanonicalPath());
       FileUtils.copyFile(artifactFile, destination);
     } catch (IOException e) {
       throw new MojoExecutionException("Unable to copy file", e);
     }
   }
 }
  private void appendPropertiesToReactorProjects(@NotNull Properties properties) {
    for (MavenProject mavenProject : reactorProjects) {
      Properties mavenProperties = mavenProject.getProperties();

      log(mavenProject.getName(), "] project", mavenProject.getName());

      for (Object key : properties.keySet()) {
        mavenProperties.put(key, properties.get(key));
      }
    }
  }
Exemple #5
0
  /**
   * Initializes the reference paths from the given project's dependencies.
   *
   * @param project The maven project.
   * @throws MojoExecutionException
   */
  @SuppressWarnings({"rawtypes", "unchecked"})
  void initReferencePaths(MavenProject project) throws MojoExecutionException {
    List deps = project.getDependencies();

    if (deps == null) {
      debug("not processing project dependencies because they're null: " + project.getName());
      return;
    }

    if (deps.size() == 0) {
      debug(
          "not processing project dependencies because they're zero length: " + project.getName());
      return;
    }

    if (this.referencePaths == null) {
      this.referencePaths = new ArrayList();
    }

    for (Object od : deps) {
      Dependency d = (Dependency) od;

      if (StringUtils.isEmpty(d.getType())) {
        continue;
      }

      if (!d.getType().matches("dll|exe")) {
        continue;
      }

      File file = DependencyUtils.getArtifactFile(super.factory, super.localRepository, d);

      if (file == null) {
        continue;
      }

      if (!this.referencePaths.contains(file.getParentFile())) {
        this.referencePaths.add(file.getParentFile());

        String assemblyName =
            DependencyUtils.getAssemblyName(
                super.factory,
                super.localRepository,
                super.mavenProject.getRemoteArtifactRepositories(),
                super.resolver,
                d);

        DependencyUtils.copyToAssemblyNamedFiles(file, assemblyName);
      }
    }
  }
  @Override
  public boolean applyChange(MavenProject project, Element root, String eol)
      throws ProjectRewriteException {
    boolean modified = false;

    if (project.hasParent()) {
      Namespace ns = getNamespaceOrNull(root);
      Element parentVersionElement = root.getChild("parent", ns).getChild("version", ns);
      MavenProject parent = project.getParent();
      String parentId = ArtifactUtils.versionlessKey(parent.getGroupId(), parent.getArtifactId());

      String parentVersion = releaseVersions.get(parentId);
      if (null == parentVersion && consistentProjectVersions && releaseVersions.size() > 0) {
        // Use any release version, as the project's versions are consistent/global
        parentVersion = releaseVersions.values().iterator().next();
      }

      if (null == parentVersion) {
        if (parent.getVersion().equals(originalVersions.get(parentId))) {
          throw new ProjectRewriteException(
              "Release version for parent " + parent.getName() + " was not found");
        }
      } else {
        workLog.add("setting parent version to '" + parentVersion + "'");
        parentVersionElement.setText(parentVersion);
        modified = true;
      }
    }

    return modified;
  }
 @SuppressWarnings("unchecked")
 @Before
 public void setup() throws ClassNotFoundException, DependencyResolutionRequiredException {
   MockitoAnnotations.initMocks(this);
   when(project.getCompileClasspathElements()).thenReturn(Arrays.asList("foo", "bar"));
   when(project.getName()).thenReturn(PROJECT_NAME);
 }
  /**
   * Loads the dependency tree for the project via {@link #loadDependencyTree(MavenProject)} and
   * then uses the {@link DependencyNodeVisitor} to load the license data. If {@link #aggregating}
   * is enabled the method recurses on each child module.
   */
  @SuppressWarnings("unchecked")
  protected void parseProject(MavenProject project, DependencyNodeVisitor visitor)
      throws MojoExecutionException, MojoFailureException {
    final Log logger = this.getLog();
    logger.info("Parsing Dependencies for: " + project.getName());

    // Load and parse immediate dependencies
    final DependencyNode tree = this.loadDependencyTree(project);
    tree.accept(visitor);

    // If not including child deps don't recurse on modules
    if (!this.includeChildDependencies) {
      return;
    }

    // No child modules, return
    final List<MavenProject> collectedProjects = project.getCollectedProjects();
    if (collectedProjects == null) {
      return;
    }

    // Find all sub-modules for the project
    for (final MavenProject moduleProject : collectedProjects) {
      if (this.isExcluded(moduleProject, project.getArtifactId())) {
        continue;
      }

      this.parseProject(moduleProject, visitor);
    }
  }
  /*
   * Build Maven Project from Source using Out and Err PrintStreams for getting the output
   */
  private void buildMavenProject(Source source, PrintStream out, PrintStream err)
      throws org.uberfire.java.nio.IOException, InvalidPathException, SecurityException,
          UnsupportedOperationException, IllegalArgumentException {
    List<String> goals = new ArrayList<>();
    goals.add("package");
    Properties p = new Properties();
    p.setProperty("failIfNoTests", "false");

    final InputStream pomStream =
        org.uberfire.java.nio.file.Files.newInputStream(
            source.getPath().resolve("drools-webapp-example").resolve("pom.xml"));
    MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);

    final String expectedBinary =
        project.getArtifact().getArtifactId()
            + "-"
            + project.getArtifact().getVersion()
            + "."
            + project.getArtifact().getType();
    final org.guvnor.ala.build.maven.model.MavenProject mavenProject =
        new MavenProjectImpl(
            project.getId(),
            project.getArtifact().getType(),
            project.getName(),
            expectedBinary,
            source.getPath(),
            source.getPath().resolve("drools-webapp-example"),
            source.getPath().resolve("target").resolve(expectedBinary).toAbsolutePath(),
            null,
            null);
    final File pom = new File(getRepositoryVisitor(mavenProject).getRoot(), "pom.xml");
    MavenBuildExecutor.executeMaven(pom, out, err, p, goals.toArray(new String[0]));
  }
 /** @see org.apache.maven.plugin.Mojo#execute() */
 public void execute() throws MojoExecutionException, MojoFailureException {
   getLog().info("Configuring Jetty for project: " + project.getName());
   if (skip) {
     getLog().info("Skipping Jetty start: jetty.skip==true");
     return;
   }
   PluginLog.setLog(getLog());
   Runtime.getRuntime().addShutdownHook(new ShutdownThread());
   random = new Random();
   startJettyRunner();
 }
  @Override
  public void sessionStarted(ExecutionEvent event) {
    if (logger.isInfoEnabled() && event.getSession().getProjects().size() > 1) {
      logger.info(chars('-', LINE_LENGTH));

      logger.info("Reactor Build Order:");

      logger.info("");

      for (MavenProject project : event.getSession().getProjects()) {
        logger.info(project.getName());
      }
    }
  }
  public Manifest getManifest() throws MojoExecutionException {
    Manifest m = new Manifest();

    Attributes attributes = m.getMainAttributes();

    attributes.put(java.util.jar.Attributes.Name.MANIFEST_VERSION, "1.0");

    attributes.putValue("Bundle-ManifestVersion", "2");
    Artifact artifact = project.getArtifact();
    attributes.putValue("Bundle-Version", getBundleVersion(artifact, true));
    attributes.putValue("Bundle-Name", project.getName());

    String symbolicName = (String) manifestAttributes.get("Bundle-SymbolicName");
    if (symbolicName == null) {
      symbolicName =
          getBundleSymbolicName(artifact.getGroupId(), artifact.getArtifactId())
              + ";singleton:=true";
    }
    attributes.putValue("Bundle-SymbolicName", symbolicName);

    if (organization != null) {
      attributes.putValue("Bundle-Vendor", organization);
    }

    attributes.putValue("Bundle-ClassPath", getBundleClasspath());

    String exportedPackages = getExportedPackages();
    if (exportedPackages != null) {
      attributes.putValue("Export-Package", exportedPackages);
    }

    String requiredBundles = getRequiredBundles();
    if (requiredBundles != null) {
      attributes.putValue("Require-Bundle", requiredBundles);
    }

    if (manifestAttributes != null) {
      for (Iterator i = manifestAttributes.entrySet().iterator(); i.hasNext(); ) {
        Entry e = (Entry) i.next();
        attributes.putValue((String) e.getKey(), (String) e.getValue());
      }
    }

    return m;
  }
  /** initialize properties shared with template */
  protected void initTemplateProperties() {

    processProperties();

    getProperties().put("pageTitle", getTitle());
    getProperties().put("parentPageTitle", getParentPageTitle());
    getProperties().put("artifactId", project.getArtifactId());
    getProperties().put("version", project.getVersion());
    getProperties().put("groupId", project.getGroupId());
    getProperties().put("name", project.getName());
    getProperties().put("description", project.getDescription());

    java.util.Properties projectProps = project.getProperties();

    if (projectProps != null) {

      for (Map.Entry<Object, Object> e : projectProps.entrySet()) {
        getProperties().put(String.valueOf(e.getKey()), String.valueOf(e.getValue()));
      }
    }
  }
  private boolean runMavenGoal(final IProject project, final IProgressMonitor monitor)
      throws CoreException {
    boolean retval = false;

    final IMavenProjectFacade facade = MavenUtil.getProjectFacade(project, monitor);
    final String pluginType = MavenUtil.getLiferayMavenPluginType(facade.getMavenProject(monitor));
    final MavenProject parentProject = facade.getMavenProject(monitor).getParent();
    final String goal = getMavenDeployGoals();

    if (isServiceBuilderProject(project, pluginType, parentProject)) {
      retval =
          execMavenLaunch(
              ProjectUtil.getProject(parentProject.getName()),
              " package -am -pl " + project.getName(),
              MavenUtil.getProjectFacade(project, monitor),
              monitor);
    } else {
      retval = execMavenLaunch(project, goal, facade, monitor);
    }

    return retval;
  }
 private Map<String, String> mergeProperties(Document document) {
   // first put systen environment
   Map<String, String> props = new LinkedHashMap<String, String>(System.getenv());
   // then add ${project.XYZ} properties
   props.put("project.groupId", project.getGroupId());
   props.put("project.artifactId", project.getArtifactId());
   props.put("project.version", project.getVersion());
   props.put("project.name", project.getName());
   props.put("project.description", project.getDescription());
   props.put("project.inceptionYear", project.getInceptionYear());
   props.put("project.url", project.getUrl());
   // then add per document properties
   props.put("file.name", document.getFile().getName());
   // we override by properties in the POM
   if (this.properties != null) {
     props.putAll(this.properties);
   }
   // then we override by java system properties (command-line -D...)
   for (String key : System.getProperties().stringPropertyNames()) {
     props.put(key, System.getProperty(key));
   }
   return props;
 }
  private void logReactorSummary(MavenSession session) {
    logger.info(chars('-', LINE_LENGTH));

    logger.info("Reactor Summary:");

    logger.info("");

    MavenExecutionResult result = session.getResult();

    for (MavenProject project : session.getProjects()) {
      StringBuilder buffer = new StringBuilder(128);

      buffer.append(project.getName());

      buffer.append(' ');
      while (buffer.length() < LINE_LENGTH - 21) {
        buffer.append('.');
      }
      buffer.append(' ');

      BuildSummary buildSummary = result.getBuildSummary(project);

      if (buildSummary == null) {
        buffer.append("SKIPPED");
      } else if (buildSummary instanceof BuildSuccess) {
        buffer.append("SUCCESS [");
        buffer.append(getFormattedTime(buildSummary.getTime()));
        buffer.append("]");
      } else if (buildSummary instanceof BuildFailure) {
        buffer.append("FAILURE [");
        buffer.append(getFormattedTime(buildSummary.getTime()));
        buffer.append("]");
      }

      logger.info(buffer.toString());
    }
  }
  public void testProjectInheritance() throws Exception {
    File localRepo = getLocalRepositoryPath();

    System.out.println("Local repository is at: " + localRepo.getAbsolutePath());

    File pom0 = new File(localRepo, "p0/pom.xml");
    File pom1 = new File(pom0.getParentFile(), "p1/pom.xml");
    File pom2 = new File(pom1.getParentFile(), "p2/pom.xml");
    File pom3 = new File(pom2.getParentFile(), "p3/pom.xml");
    File pom4 = new File(pom3.getParentFile(), "p4/pom.xml");
    File pom5 = new File(pom4.getParentFile(), "p5/pom.xml");

    System.out.println("Location of project-4's POM: " + pom4.getPath());

    // load everything...
    MavenProject project0 = getProject(pom0);
    MavenProject project1 = getProject(pom1);
    MavenProject project2 = getProject(pom2);
    MavenProject project3 = getProject(pom3);
    MavenProject project4 = getProject(pom4);
    MavenProject project5 = getProject(pom5);

    assertEquals("p4", project4.getName());

    // ----------------------------------------------------------------------
    // Value inherited from p3
    // ----------------------------------------------------------------------

    assertEquals("2000", project4.getInceptionYear());

    // ----------------------------------------------------------------------
    // Value taken from p2
    // ----------------------------------------------------------------------

    assertEquals("mailing-list", project4.getMailingLists().get(0).getName());

    // ----------------------------------------------------------------------
    // Value taken from p1
    // ----------------------------------------------------------------------

    assertEquals("scm-url/p2/p3/p4", project4.getScm().getUrl());

    // ----------------------------------------------------------------------
    // Value taken from p4
    // ----------------------------------------------------------------------

    assertEquals("Codehaus", project4.getOrganization().getName());

    // ----------------------------------------------------------------------
    // Value taken from super model
    // ----------------------------------------------------------------------

    assertEquals("4.0.0", project4.getModelVersion());

    Build build = project4.getBuild();
    List plugins = build.getPlugins();

    Map validPluginCounts = new HashMap();

    String testPluginArtifactId = "maven-compiler-plugin";

    // this is the plugin we're looking for.
    validPluginCounts.put(testPluginArtifactId, 0);

    // these are injected if -DperformRelease=true
    validPluginCounts.put("maven-deploy-plugin", 0);
    validPluginCounts.put("maven-javadoc-plugin", 0);
    validPluginCounts.put("maven-source-plugin", 0);

    Plugin testPlugin = null;

    for (Iterator it = plugins.iterator(); it.hasNext(); ) {
      Plugin plugin = (Plugin) it.next();

      String pluginArtifactId = plugin.getArtifactId();

      if (!validPluginCounts.containsKey(pluginArtifactId)) {
        fail("Illegal plugin found: " + pluginArtifactId);
      } else {
        if (pluginArtifactId.equals(testPluginArtifactId)) {
          testPlugin = plugin;
        }

        Integer count = (Integer) validPluginCounts.get(pluginArtifactId);

        if (count.intValue() > 0) {
          fail("Multiple copies of plugin: " + pluginArtifactId + " found in POM.");
        } else {
          count = count.intValue() + 1;

          validPluginCounts.put(pluginArtifactId, count);
        }
      }
    }

    List executions = testPlugin.getExecutions();

    assertEquals(1, executions.size());
  }
 protected File projectSandboxDirectory() {
   return new File(pluginsSandboxDirectory(), project.getName());
 }
  /**
   * Format the given artifact as a bundle string with the appropriate syntax used by the karaf
   * features.xml file. For example:
   *
   * <p>mvn:commons-configuration/commons-configuration/1.6
   *
   * @param artifact
   */
  protected String formatArtifactAsBundle(Artifact artifact) throws Exception {
    StringBuilder builder = new StringBuilder();
    // If it's a bundle already, awesome.  If not, we need to wrap it
    // and include some useful meta-data.
    if (isBundle(artifact)) {
      // Example:  mvn:commons-configuration/commons-configuration/1.6
      builder.append("mvn:"); // $NON-NLS-1$
      builder.append(artifact.getGroupId());
      builder.append("/"); // $NON-NLS-1$
      builder.append(artifact.getArtifactId());
      builder.append("/"); // $NON-NLS-1$
      builder.append(artifact.getBaseVersion());
      String classifier = artifact.getClassifier();
      if (classifier != null && classifier.trim().length() == 0) {
        classifier = null;
      }
      if (!"jar".equalsIgnoreCase(artifact.getType()) || classifier != null) { // $NON-NLS-1$
        builder.append("/"); // $NON-NLS-1$
        builder.append(artifact.getType());
      }
      if (classifier != null) {
        builder.append("/"); // $NON-NLS-1$
        builder.append(classifier);
      }
    } else {
      // Example:
      // wrap:mvn:log4j/log4j/1.2.14$Bundle-SymbolicName=log4j.log4j&amp;Bundle-Version=1.2.14&amp;Bundle-Name=Log4j
      builder.append("wrap:mvn:"); // $NON-NLS-1$
      builder.append(artifact.getGroupId());
      builder.append("/"); // $NON-NLS-1$
      builder.append(artifact.getArtifactId());
      builder.append("/"); // $NON-NLS-1$
      builder.append(artifact.getBaseVersion());
      String classifier = artifact.getClassifier();
      if (classifier != null && classifier.trim().length() == 0) {
        classifier = null;
      }
      if (!"jar".equalsIgnoreCase(artifact.getType()) || classifier != null) { // $NON-NLS-1$
        builder.append("/"); // $NON-NLS-1$
        builder.append(artifact.getType());
      }
      if (classifier != null) {
        builder.append("/"); // $NON-NLS-1$
        builder.append(classifier);
      }

      MavenProject project = resolveProject(artifact);
      builder.append("$Bundle-SymbolicName="); // $NON-NLS-1$
      builder.append(artifact.getGroupId());
      builder.append("."); // $NON-NLS-1$
      builder.append(artifact.getArtifactId());
      builder.append("&Bundle-Version="); // $NON-NLS-1$
      builder.append(sanitizeVersionForOsgi(artifact.getBaseVersion()));
      // Under certain circumstances, the project name may include unresolved variables.  If so,
      // skip Bundle-Name
      if (project.getName() != null
          && project.getName().trim().length() > 0
          && !project.getName().contains("${")) { // $NON-NLS-1$
        builder.append("&Bundle-Name="); // $NON-NLS-1$
        builder.append(project.getName());
      }
    }
    return builder.toString();
  }
Exemple #20
0
  protected void generateZip()
      throws DependencyTreeBuilderException, MojoExecutionException, IOException,
          MojoFailureException {

    File appBuildDir = buildDir;
    if (Strings.isNotBlank(pathInZip)) {
      appBuildDir = new File(buildDir, pathInZip);
    }
    appBuildDir.mkdirs();

    if (hasConfigDir()) {
      copyAppConfigFiles(appBuildDir, appConfigDir);

    } else {
      getLog()
          .info(
              "The app configuration files directory "
                  + appConfigDir
                  + " doesn't exist, so not copying any additional project documentation or configuration files");
    }
    MavenProject project = getProject();

    if (!ignoreProject) {
      File kubernetesJson = getKubernetesJson();
      if (kubernetesJson != null && kubernetesJson.isFile() && kubernetesJson.exists()) {
        File jsonFile = new File(appBuildDir, "kubernetes.json");
        jsonFile.getParentFile().mkdirs();
        Files.copy(kubernetesJson, jsonFile);
      }

      // TODO if no iconRef is specified we could try guess based on the project?

      // lets check if we can use an icon reference
      copyIconToFolder(appBuildDir);
    }

    // lets only generate a app zip if we have a requirement (e.g. we're not a parent pom packaging
    // project) and
    // we have defined some configuration files or dependencies
    // to avoid generating dummy apps for parent poms
    if (hasConfigDir() || !ignoreProject) {

      if (includeReadMe) {
        copyReadMe(appBuildDir);
      }

      if (generateSummaryFile) {
        copySummaryText(appBuildDir);
      }

      if (generateAppPropertiesFile) {
        String name = project.getName();
        if (Strings.isNullOrBlank(name)) {
          name = project.getArtifactId();
        }
        String description = project.getDescription();
        Properties appProperties = new Properties();
        appProperties.put("name", name);
        if (Strings.isNotBlank(description)) {
          appProperties.put("description", description);
        }
        appProperties.put("groupId", project.getGroupId());
        appProperties.put("artifactId", project.getArtifactId());
        appProperties.put("version", project.getVersion());
        File appPropertiesFile = new File(appBuildDir, "fabric8.properties");
        appPropertiesFile.getParentFile().mkdirs();
        if (!appPropertiesFile.exists()) {
          appProperties.store(new FileWriter(appPropertiesFile), "Fabric8 Properties");
        }
      }

      File outputZipFile = getZipFile();
      File legalDir = null;
      if (includeLegal) {
        legalDir = new File(project.getBuild().getOutputDirectory(), "META-INF");
      }
      Zips.createZipFile(getLog(), buildDir, outputZipFile, legalDir);

      projectHelper.attachArtifact(project, artifactType, artifactClassifier, outputZipFile);
      getLog().info("Created app zip file: " + outputZipFile);
    }
  }
Exemple #21
0
  public static void prepareLanguage(
      Log log,
      MavenProject project,
      MavenProjectHelper projectHelper,
      File languageOutDir,
      File schemaOutDir,
      BuildContext buildContext)
      throws MojoExecutionException {

    File camelMetaDir = new File(languageOutDir, "META-INF/services/org/apache/camel/");

    // first we need to setup the output directory because the next check
    // can stop the build before the end and eclipse always needs to know about that directory
    if (projectHelper != null) {
      projectHelper.addResource(
          project,
          languageOutDir.getPath(),
          Collections.singletonList("**/dataformat.properties"),
          Collections.emptyList());
    }

    if (!PackageHelper.haveResourcesChanged(
        log, project, buildContext, "META-INF/services/org/apache/camel/language")) {
      return;
    }

    Map<String, String> javaTypes = new HashMap<String, String>();

    StringBuilder buffer = new StringBuilder();
    int count = 0;
    for (Resource r : project.getBuild().getResources()) {
      File f = new File(r.getDirectory());
      if (!f.exists()) {
        f = new File(project.getBasedir(), r.getDirectory());
      }
      f = new File(f, "META-INF/services/org/apache/camel/language");

      if (f.exists() && f.isDirectory()) {
        File[] files = f.listFiles();
        if (files != null) {
          for (File file : files) {
            String javaType = readClassFromCamelResource(file, buffer, buildContext);
            if (!file.isDirectory() && file.getName().charAt(0) != '.') {
              count++;
            }
            if (javaType != null) {
              javaTypes.put(file.getName(), javaType);
            }
          }
        }
      }
    }

    // find camel-core and grab the data format model from there, and enrich this model with
    // information from this artifact
    // and create json schema model file for this data format
    try {
      if (count > 0) {
        Artifact camelCore = findCamelCoreArtifact(project);
        if (camelCore != null) {
          File core = camelCore.getFile();
          if (core != null) {
            URL url = new URL("file", null, core.getAbsolutePath());
            URLClassLoader loader = new URLClassLoader(new URL[] {url});
            for (Map.Entry<String, String> entry : javaTypes.entrySet()) {
              String name = entry.getKey();
              String javaType = entry.getValue();
              String modelName = asModelName(name);

              InputStream is =
                  loader.getResourceAsStream(
                      "org/apache/camel/model/language/" + modelName + ".json");
              if (is == null) {
                // use file input stream if we build camel-core itself, and thus do not have a JAR
                // which can be loaded by URLClassLoader
                is =
                    new FileInputStream(
                        new File(core, "org/apache/camel/model/language/" + modelName + ".json"));
              }
              String json = loadText(is);
              if (json != null) {
                LanguageModel languageModel = new LanguageModel();
                languageModel.setName(name);
                languageModel.setTitle("");
                languageModel.setModelName(modelName);
                languageModel.setLabel("");
                languageModel.setDescription("");
                languageModel.setJavaType(javaType);
                languageModel.setGroupId(project.getGroupId());
                languageModel.setArtifactId(project.getArtifactId());
                languageModel.setVersion(project.getVersion());

                List<Map<String, String>> rows =
                    JSonSchemaHelper.parseJsonSchema("model", json, false);
                for (Map<String, String> row : rows) {
                  if (row.containsKey("title")) {
                    languageModel.setTitle(row.get("title"));
                  }
                  if (row.containsKey("description")) {
                    languageModel.setDescription(row.get("description"));
                  }
                  if (row.containsKey("label")) {
                    languageModel.setLabel(row.get("label"));
                  }
                  if (row.containsKey("javaType")) {
                    languageModel.setModelJavaType(row.get("javaType"));
                  }
                }
                log.debug("Model " + languageModel);

                // build json schema for the data format
                String properties = after(json, "  \"properties\": {");
                String schema = createParameterJsonSchema(languageModel, properties);
                log.debug("JSon schema\n" + schema);

                // write this to the directory
                File dir = new File(schemaOutDir, schemaSubDirectory(languageModel.getJavaType()));
                dir.mkdirs();

                File out = new File(dir, name + ".json");
                OutputStream fos = buildContext.newFileOutputStream(out);
                fos.write(schema.getBytes());
                fos.close();

                buildContext.refresh(out);

                log.debug("Generated " + out + " containing JSon schema for " + name + " language");
              }
            }
          }
        }
      }
    } catch (Exception e) {
      throw new MojoExecutionException(
          "Error loading language model from camel-core. Reason: " + e, e);
    }

    if (count > 0) {
      Properties properties = new Properties();
      String names = buffer.toString();
      properties.put("languages", names);
      properties.put("groupId", project.getGroupId());
      properties.put("artifactId", project.getArtifactId());
      properties.put("version", project.getVersion());
      properties.put("projectName", project.getName());
      if (project.getDescription() != null) {
        properties.put("projectDescription", project.getDescription());
      }

      camelMetaDir.mkdirs();
      File outFile = new File(camelMetaDir, "language.properties");

      // check if the existing file has the same content, and if so then leave it as is so we do not
      // write any changes
      // which can cause a re-compile of all the source code
      if (outFile.exists()) {
        try {
          Properties existing = new Properties();

          InputStream is = new FileInputStream(outFile);
          existing.load(is);
          is.close();

          // are the content the same?
          if (existing.equals(properties)) {
            log.debug("No language changes detected");
            return;
          }
        } catch (IOException e) {
          // ignore
        }
      }

      try {
        OutputStream os = buildContext.newFileOutputStream(outFile);
        properties.store(os, "Generated by camel-package-maven-plugin");
        os.close();

        log.info(
            "Generated "
                + outFile
                + " containing "
                + count
                + " Camel "
                + (count > 1 ? "languages: " : "language: ")
                + names);

        if (projectHelper != null) {
          projectHelper.attachArtifact(project, "properties", "camelLanguage", outFile);
        }
      } catch (IOException e) {
        throw new MojoExecutionException(
            "Failed to write properties to " + outFile + ". Reason: " + e, e);
      }
    } else {
      log.debug(
          "No META-INF/services/org/apache/camel/language directory found. Are you sure you have created a Camel language?");
    }
  }