2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.jetbrains
.idea
.devkit
.run
;
18 import com
.intellij
.openapi
.application
.PathManager
;
19 import com
.intellij
.openapi
.diagnostic
.Logger
;
20 import com
.intellij
.openapi
.projectRoots
.Sdk
;
21 import com
.intellij
.openapi
.util
.io
.FileUtil
;
22 import org
.jetbrains
.annotations
.NonNls
;
23 import org
.jetbrains
.annotations
.Nullable
;
26 import java
.io
.IOException
;
32 public class IdeaLicenseHelper
{
33 @NonNls private static final String LICENSE_PATH_PREFERRED
= "idea80.key";
34 @NonNls private static final String LICENSE_PATH_70
= "idea70.key";
35 @NonNls private static final String LICENSE_PATH_60
= "idea60.key";
36 @NonNls private static final String LICENSE_PATH_50
= "idea50.key";
37 @NonNls private static final String LICENSE_PATH_40
= "idea40.key";
38 @NonNls private static final String LICENSE_PATH_SYSTEM
= "idea.license";
40 @NonNls private static final String CONFIG_DIR_NAME
= "config";
42 private static final Logger LOG
= Logger
.getInstance("#org.jetbrains.idea.devkit.run.IdeaLicenseHelper");
45 public static File
isIDEALicenseInSandbox(@NonNls final String configPath
, @NonNls final String systemPath
, @NonNls final String binPath
){
46 final File config
= new File(configPath
, LICENSE_PATH_PREFERRED
);
50 final File idea70
= new File(configPath
, LICENSE_PATH_70
);
54 final File idea60
= new File(configPath
, LICENSE_PATH_60
);
58 final File idea5
= new File(configPath
, LICENSE_PATH_50
);
62 final File idea4
= new File(configPath
, LICENSE_PATH_40
);
66 final File system
= new File(systemPath
, LICENSE_PATH_SYSTEM
);
70 final File bin
= new File(binPath
, LICENSE_PATH_SYSTEM
);
77 public static void copyIDEALicencse(final String sandboxHome
, Sdk jdk
){
78 if (isIDEALicenseInSandbox(sandboxHome
+ File
.separator
+ CONFIG_DIR_NAME
, sandboxHome
+ File
.separator
+ "system", jdk
.getHomePath() + File
.separator
+ "bin") == null){
79 final File ideaLicense
= isIDEALicenseInSandbox(PathManager
.getConfigPath(), PathManager
.getSystemPath(), PathManager
.getBinPath());
80 if (ideaLicense
!= null){
82 FileUtil
.copy(ideaLicense
, new File(new File(sandboxHome
, CONFIG_DIR_NAME
), LICENSE_PATH_PREFERRED
));
84 catch (IOException e
) {