<commit_before>/*
 * Copyright (C) 2015 AXON IVY AG
 *
 * 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 ch.ivyteam.ivy.maven;


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;

/**
 * Downloads an AXON.IVY Engine from the NET if it does not yet exists in the correct version.
 * 
 * 
 * <p>Command line invocation is supported. E.g.</p>
 * <pre>mvn com.axonivy.ivy.ci:project-build-plugin:6.1.0-SNAPSHOT:installEngine
 * -Divy.engine.directory=c:/axonviy/engine
 * -Divy.engine.version=6.1.0
 * -Divy.engine.os.arch=Linux_x64</pre>
 * 
 * @author <NAME>
 * @since 6.0.0
 */
@Mojo(name=InstallEngineMojo.GOAL, requiresProject=false)
public class InstallEngineMojo extends AbstractEngineMojo
{
  public static final String GOAL = "installEngine";
  public static final String ENGINE_LIST_URL_PROPERTY = "ivy.engine.list.url";
  
  /**
   * URL where a packed ivy Engine can be downloaded. E.g.
   * <code>http://developer.axonivy.com/download/6.0.0/AxonIvyEngine6.0.0.46949_Windows_x86.zip</code>
   */
  @Parameter(property="ivy.engine.download.url")
  URL engineDownloadUrl;
  
  /** 
   * URL where a link to the ivy Engine in the expected {@link #ivyVersion} exists. 
   * The URL will be used to download the required engine if it does not yet exist.
   * The URL should point to a site providing HTML content with a link to the engine <br>e.g.
   * <code>&lt;a href="http://developer.axonivy.com/download/6.0.0/AxonIvyEngine6.0.0.46949_Windows_x86.zip"&gt; the engine&lt;/a&gt;</code>
   */
  @Parameter(defaultValue="http://developer.axonivy.com/download/maven.html", property=ENGINE_LIST_URL_PROPERTY)
  URL engineListPageUrl;
  
  /** 
   * Engine type that will be downloaded if {@link #autoInstallEngine} is set and the engine must be 
   * retrieved from the {@link #engineListPageUrl}.
   * Possible values are:
   * <ul>
   *    <li>Linux_x64</li>
   *    <li>Windows_x64</li>
   *    <li>Windows_x86</li>
   * </ul>
   */
  @Parameter(defaultValue="Windows_x64", property="ivy.engine.os.arch")
  String osArchitecture;
  
  /** 
   * Enables the automatic installation of an ivy Engine in the {@link #engineDirectory}.
   * If there is yet no engine installed, or the {@link #ivyVersion} does not match, the
   * engine will be downloaded from the {@link #engineDownloadUrl} and unpacked into the
   * {@link #engineDirectory}.
   */
  @Parameter(defaultValue="true", property="ivy.engine.auto.install") 
  boolean autoInstallEngine;

  @Override
  public void execute() throws MojoExecutionException
  {
    getLog().info("Compiling project for ivy version " + ivyVersion);
    ensureEngineIsInstalled();
  }

  private void ensureEngineIsInstalled() throws MojoExecutionException
  {
    if (identifyAndGetEngineDirectory() == null)
    {
      handleNoInstalledEngine();
    }<commit_msg>Fix missleading log output during engine install<commit_after>/*
 * Copyright (C) 2015 AXON IVY AG
 *
 * 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 ch.ivyteam.ivy.maven;


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;

/**
 * Downloads an AXON.IVY Engine from the NET if it does not yet exists in the correct version.
 * 
 * 
 * <p>Command line invocation is supported. E.g.</p>
 * <pre>mvn com.axonivy.ivy.ci:project-build-plugin:6.1.0-SNAPSHOT:installEngine
 * -Divy.engine.directory=c:/axonviy/engine
 * -Divy.engine.version=6.1.0
 * -Divy.engine.os.arch=Linux_x64</pre>
 * 
 * @author <NAME>
 * @since 6.0.0
 */
@Mojo(name=InstallEngineMojo.GOAL, requiresProject=false)
public class InstallEngineMojo extends AbstractEngineMojo
{
  public static final String GOAL = "installEngine";
  public static final String ENGINE_LIST_URL_PROPERTY = "ivy.engine.list.url";
  
  /**
   * URL where a packed ivy Engine can be downloaded. E.g.
   * <code>http://developer.axonivy.com/download/6.0.0/AxonIvyEngine6.0.0.46949_Windows_x86.zip</code>
   */
  @Parameter(property="ivy.engine.download.url")
  URL engineDownloadUrl;
  
  /** 
   * URL where a link to the ivy Engine in the expected {@link #ivyVersion} exists. 
   * The URL will be used to download the required engine if it does not yet exist.
   * The URL should point to a site providing HTML content with a link to the engine <br>e.g.
   * <code>&lt;a href="http://developer.axonivy.com/download/6.0.0/AxonIvyEngine6.0.0.46949_Windows_x86.zip"&gt; the engine&lt;/a&gt;</code>
   */
  @Parameter(defaultValue="http://developer.axonivy.com/download/maven.html", property=ENGINE_LIST_URL_PROPERTY)
  URL engineListPageUrl;
  
  /** 
   * Engine type that will be downloaded if {@link #autoInstallEngine} is set and the engine must be 
   * retrieved from the {@link #engineListPageUrl}.
   * Possible values are:
   * <ul>
   *    <li>Linux_x64</li>
   *    <li>Windows_x64</li>
   *    <li>Windows_x86</li>
   * </ul>
   */
  @Parameter(defaultValue="Windows_x64", property="ivy.engine.os.arch")
  String osArchitecture;
  
  /** 
   * Enables the automatic installation of an ivy Engine in the {@link #engineDirectory}.
   * If there is yet no engine installed, or the {@link #ivyVersion} does not match, the
   * engine will be downloaded from the {@link #engineDownloadUrl} and unpacked into the
   * {@link #engineDirectory}.
   */
  @Parameter(defaultValue="true", property="ivy.engine.auto.install") 
  boolean autoInstallEngine;

  @Override
  public void execute() throws MojoExecutionException
  {
    getLog().info("Provide engine for ivy version " + ivyVersion);
    ensureEngineIsInstalled();
  }

  private void ensureEngineIsInstalled() throws MojoExecutionException
  {
    if (identifyAndGetEngineDirectory() == null)
    {
      handleNoInstalledEngine();
    }
{'fraction_non_alphanumeric': 0.1124274661508704, 'fraction_numerical': 0.01402321083172147, 'mean_word_length': 4.135319677219119, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4041041', 'n_tokens_mistral': 2710, 'n_tokens_neox': 2582, 'n_words': 704}