Skip to content

Commit

Permalink
eclipse-che#2509 create project.json file in C# project (eclipse-che#…
Browse files Browse the repository at this point in the history
…2587)

* eclipse-che#2509 create project.json file in C# project
  • Loading branch information
Evgen Vidolob authored Sep 26, 2016
1 parent dddeada commit 964a93b
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 1 deletion.
12 changes: 12 additions & 0 deletions plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<findbugs.failonerror>false</findbugs.failonerror>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
Expand All @@ -32,6 +36,10 @@
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
Expand All @@ -44,5 +52,9 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-csharp-lang-shared</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;

import org.eclipse.che.api.project.server.handlers.ProjectHandler;
import org.eclipse.che.api.project.server.type.ProjectTypeDef;
import org.eclipse.che.inject.DynaModule;
import org.eclipse.che.plugin.csharp.projecttype.CSharpProjectType;
import org.eclipse.che.plugin.csharp.projecttype.CreateNetCoreProjectHandler;

/**
* @author Anatolii Bazko
Expand All @@ -26,5 +28,8 @@ public class CSharpModule extends AbstractModule {
protected void configure() {
Multibinder<ProjectTypeDef> projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class);
projectTypeMultibinder.addBinding().to(CSharpProjectType.class);

Multibinder<ProjectHandler> projectHandlersMultibinder = Multibinder.newSetBinder(binder(), ProjectHandler.class);
projectHandlersMultibinder.addBinding().to(CreateNetCoreProjectHandler.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class CSharpProjectType extends ProjectTypeDef {
@Inject
public CSharpProjectType() {
super(Constants.CSHARP_PROJECT_TYPE_ID, "C#", true, false, true);
super(Constants.CSHARP_PROJECT_TYPE_ID, "C# .NET Core", true, false, true);
addConstantDefinition(Constants.LANGUAGE, "language", Constants.CSHARP_LANG);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2012-2016 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.plugin.csharp.projecttype;

import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.project.server.FolderEntry;
import org.eclipse.che.api.project.server.handlers.CreateProjectHandler;
import org.eclipse.che.api.project.server.type.AttributeValue;
import org.eclipse.che.plugin.csharp.shared.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Map;

import static com.google.common.io.Resources.getResource;
import static com.google.common.io.Resources.toByteArray;

/**
* @author Evgen Vidolob
*/
public class CreateNetCoreProjectHandler implements CreateProjectHandler {

private static final Logger LOG = LoggerFactory.getLogger(CreateNetCoreProjectHandler.class);

private final String PROJECT_FILE_NAME = "project.json";


@Override
public void onCreateProject(FolderEntry baseFolder, Map<String, AttributeValue> attributes, Map<String, String> options)
throws ForbiddenException, ConflictException, ServerException {
baseFolder.createFile(PROJECT_FILE_NAME, getProjectContent());

}

private byte[] getProjectContent() {
String filename = "project.json.default";
try {
return toByteArray(getResource(filename));
} catch (IOException e) {
LOG.warn("File %s not found so content of %s will be empty.", filename, PROJECT_FILE_NAME);
return new byte[0];
}
}

@Override
public String getProjectType() {
return Constants.CSHARP_PROJECT_TYPE_ID;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-3002702"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}

0 comments on commit 964a93b

Please sign in to comment.